我可以从头开始创建一个excel并将批量数据写入其中,但在使用模板时它无法正常工作。我认为这是由于一些与属性相关的问题而无法纠正的。你能帮忙吗?在模板中前3行是标题和标题,那么我如何跳过这些行并从第4行开始? 这是我的代码
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
}
}