i trying create excel spreadsheet using openxml 2.0 , c#. can able create plain excel without format data table values database. but, when try create new style apply on specific fields, excel created unable open , throws error message:
excel has stopped working.
below code use create stylesheet.
spreadsheetdocument spreadsheetdocument = spreadsheetdocument.create(filepath,spreadsheetdocumenttype.workbook); // add workbookpart document. workbookpart workbookpart = spreadsheetdocument.addworkbookpart(); workbookpart.workbook = new workbook(); workbookpart.workbook.save(); // add worksheetpart workbookpart. worksheetpart worksheetpart = workbookpart.addnewpart<worksheetpart>(); worksheetpart.worksheet = new worksheet(new sheetdata()); worksheetpart.worksheet.save(); workbookstylespart stylepart = spreadsheetdocument.workbookpart.addnewpart<workbookstylespart>(); stylesheet stylesheet = new stylesheet(); cellformats cellformats = new cellformats() { count = (uint32value)1u }; cellformat cellformat = new cellformat(new alignment { wraptext = true }); cellformats.append(cellformat); stylesheet.append(cellformats); stylesheet.save(stylepart); //stylepart.stylesheet = stylesheet; //stylepart.stylesheet.save(); uint32value styleindex = stylesheet.cellformats.count; can please fix issue. if comment stylesheet creation part, excel generated , accessing perfectly. can 1 check , explain going wrong.
Comments
Post a Comment