I want to create a spreadsheet with DocumentFormat.OpenXML. I've been having a really hard time getting it to work, so I thought I'd ask for help here.
I would like to programmatically create a spreadsheet at runtime to be downloaded from an ASP.net web site.
(1) I want the spreadsheet to contain some rows of data from a SQL Database. I want the row headers to consist of black text on a yellow background. I ha开发者_StackOverflowve some string data, which incidently, may contain strings of digits. I want it to be treated as a string at all times (ie, I don't want 31415926535 to be presented as 3.1415926e10)
(2) I would like to have a 300px x 300px PNG image appear below the last row of data. The image is saved on the server as hello.png.
What code do I need to write to make (1) and (2) happen?
I've recently done something similar. I believe the best way to accomplish what you need is to first create a template Excel
spreadsheet. Then, using Open XML Productivity Tool
, reflect the code needed to create it.
Reading through the limited documentation left me spinning my wheels until I started using the Productivity Tool
. It does generate some extraneous code but it gets you to the meat and is very helpful.
精彩评论