0

I could create an excel from scratch and write bulk data into it but it's not working while using a template. I think it is happening due to some attribute related issues but unable to rectify. Could you please help on this? Also in the template first 3 lines are title and headings, so how I can skip those lines and start from 4th row? Here is my code

string newFileName = @"C:\Users\Jeremy\Desktop\OpenXML\Test.xlsm";
using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Open(newFileName, true))
{
    WorkbookPart workbookPart = spreadSheet.WorkbookPart;
    var openXmlExportHelper = new OpenXmlWriterHelper();
    Sheet sheet = workbookPart.Workbook.Descendants<Sheet>().Where(s => s.Name == "Sheet1").FirstOrDefault();
    WorksheetPart worksheetPart = workbookPart.GetPartById(sheet.Id.Value) as WorksheetPart;
    using (var writer = OpenXmlWriter.Create(worksheetPart))
    {
        writer.WriteStartElement(new Row());
        openXmlExportHelper.WriteCellValueSax(writer, "Cell A4", CellValues.InlineString);
        writer.WriteEndElement(); //end of Row

    }
}
jvin
  • 5
  • 4
  • 1
    Stackoverflow is not a website to ask people to code for you but to ask for specific problems that after trying for a while you weren't able to solve in your own. What have you tried so far and why did results on search engines did you help you? – Capricorn Jun 16 '18 at 15:46
  • I found resources mostly explains the DOM model which is taking too long and sometimes giving memory issues. I couldn't find much about the SAX approach and that's why I asked this question. – jvin Jun 16 '18 at 18:12
  • Have a look at my answer here - https://stackoverflow.com/questions/32690851/export-big-amount-of-data-from-xlsx-outofmemoryexception/32787219#32787219. It shows a SAX example. – petelids Jun 18 '18 at 09:10

0 Answers0