c# - Cell Values Incorrect - OpenXML Excel -
i trying read excel values in .xlsm - code below. problem i'm having values displayed wrong, nothing @ similar.
using (spreadsheetdocument spreadsheetdocument = spreadsheetdocument.open(filename, false)) { workbookpart workbookpart = spreadsheetdocument.workbookpart; sheet sheet = workbookpart.workbook.sheets.elements<sheet>().first(s => s.name.hasvalue && s.name.value == "y1 dose history"); worksheetpart worksheetpart = (worksheetpart)workbookpart.getpartbyid(sheet.id); //sheetdata data = worksheetpart.worksheet.elements<sheetdata>().first(); neither line nor next work sheetdata data = worksheetpart.worksheet.getfirstchild<sheetdata>(); string text; foreach (row row in data.elements<row>()) { text = null; foreach (cell cell in row.elements<cell>()) { if (cell.cellvalue != null) { text = text + " " + cell.cellvalue.innerxml.tostring(); } } console.writeline(text); } console.readline(); }
Comments
Post a Comment