I'm brand new to Open XML for Excel and am finding that I spend most of my time spinning my wheels with it (Has anyone else had this experience?)
I'm trying to convert some code that used to use interop Excel objects and will now use Open XML. I am running into some very serious roadblocks.
Most notably:
I can create a new Excel document with one sheet named "Sheet 1". There is nothing in it yet, but I can create it. What I need to do is:
1. Format the columns (width, data type, font)
2. Add column headings (I can add the text, only. I can't format the headings -- see item 3)
3. Format the column headings (bold, background color, border along the bottom of the cells)
3. Populate the worksheet starting at row 2 with data from one of 3 possible sources (SQL dataset, DataGridView contents, CSV file)
Format the columns. I haven't found any examples of formatting existing columns, only adding new ones. If I do that, then when I save the document it gets into a corrupted state)
Add column headings. It appears that I can do this but only adding the text.
Format the column headings. Again, since I can't find examples of formatting existing columns, I can't change the headings to be the way I want them.
Populate the worksheet. When I used interop.Excel, I was able to convert the DataSet into an ADODB recordset, and populate the entire worksheet very quickly. I don't find any examples of doing this with Open XML. All I find is individual cell updates which will take forever to do if there are a few thousand rows of 20+ columns.
If anybody has a good (and I stress GOOD) tutorial on Open XML or can share their experiences with me, that would be greatly appreciated.
Jerry Scannell
I'm trying to convert some code that used to use interop Excel objects and will now use Open XML. I am running into some very serious roadblocks.
Most notably:
I can create a new Excel document with one sheet named "Sheet 1". There is nothing in it yet, but I can create it. What I need to do is:
1. Format the columns (width, data type, font)
2. Add column headings (I can add the text, only. I can't format the headings -- see item 3)
3. Format the column headings (bold, background color, border along the bottom of the cells)
3. Populate the worksheet starting at row 2 with data from one of 3 possible sources (SQL dataset, DataGridView contents, CSV file)
Format the columns. I haven't found any examples of formatting existing columns, only adding new ones. If I do that, then when I save the document it gets into a corrupted state)
Add column headings. It appears that I can do this but only adding the text.
Format the column headings. Again, since I can't find examples of formatting existing columns, I can't change the headings to be the way I want them.
Populate the worksheet. When I used interop.Excel, I was able to convert the DataSet into an ADODB recordset, and populate the entire worksheet very quickly. I don't find any examples of doing this with Open XML. All I find is individual cell updates which will take forever to do if there are a few thousand rows of 20+ columns.
If anybody has a good (and I stress GOOD) tutorial on Open XML or can share their experiences with me, that would be greatly appreciated.
Jerry Scannell