c# - OpenXML Spreadsheet get column ordinal index -
i'm creating excel export using openxml libraries. able set cell reference using default cell references e.g. a1.
as want dynamically populate data across columns wondering if it's possible use numerical co-ordinate reference e.g. cells[1, 1]?
so instead of doing like:
cell cell = insertcellinworksheet("a", 1, worksheet);
i do:
cell cell = insertcellinworksheet(columnindex, rowindex, worksheet);
i seem find lot of examples using excel grid reference ("a1") nothing numerical representation.
many
andy
update
i have found way of getting column headers via answer here calculates column name based on numerical index.
this gets column fine, can step through code , can see cycling through columns z, aa, ab etc. finding when iterating through columns if builds past column z error message excel found unreadable content in...do want recover contents of workbook? if trust source of workbook, click yes.
this code sets cells:
int columnindex = 1; string col; uint rowindex = 60; foreach (var item in _data) { col = excelhelper.getcolumnname(columnindex); excelhelper.setcell(wsp, col, rowindex, item.periodend.tostring("dd/mm/yyyy"), excelstylesheet.tablecell); columnindex++; }
if hard code col "aa" , set rowindex incrementing works fine generates unreadable excel file.
i can't see how/why happening can see col
being set correctly stepping through code appears going awry somewhere.
can shed light on causing or know of approach identify issue better?
thanks again
andy
you can use following code
row.append(newcell);
instead of this
row.insertbefore(newcell, refcell);
open xml sdk: "unreadable content" error when trying populate more 25 columns
Comments
Post a Comment