Create and populate Excel file in c# code behind
Can anyone direct me to a place where I can learn a little bit about creating a .xslx file in code behind then populating it. I would need to create new worksheets as well.
I would be using a text box and parsing the data therein to populate the excel spreadsheet.
Thanks in 开发者_Go百科advance.
Check out the Open XML SDK 2.0 for Microsoft Office. It provides a slightly higher level API than simply the formidable Open XML specification. Download both packages - the tools are useful for experimenting.
Here are some links that should get you started using this SDK:
- Getting Started with the Open XML SDK 2.0 for Microsoft Office
- Creating Spreadsheet document using OpenXML SDK
- Creating Documents by Using the Open XML Format SDK 2.0
The question OpenXML SDK Spreadsheet starter kits also has some great links.
I used a few SDK's when I had to do it, and unfortunately many of them worked but had issues with some security when you open it in Excel again.
I eventually settled for good old COM interop with Excel.
This Interop Arcticle will help you get started.
I just created a nice ExcelHelper class to hide all the ugly COM syntax and handle the memory for me.
精彩评论