我已经使用C#中的Open XML SDK创建了一个电子表格,并成功地填充了两个工作表。
当尝试填充第三个工作表时,打开完成的文档时会出现一个“无法读取内容”错误,并且似乎是在第三个工作表上尝试填充超过25个单元格时发生的。
我正在使用与文档其他部分成功工作的相同的代码片段:
string[] headers2 = {
"Reference", "Raised", "Priority", "Affected", "Linked incidents",
"Points", "SLA", "Stopped", "Target" };
// remaining headers are month/years created on the fly
string[] headerCells = {
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH" };
...
// headers
// once we've finished the presets, the month/year pairs take over
cellNo = (uint)0;
foreach (string h in headers2)
{
cell = InsertCellInWorksheet(headerCells[cellNo++], 2, worksheetPart);
cell.CellValue = new CellValue(h);
cell.DataType = new EnumValue<CellValues>(CellValues.String);
}
string[] monthYears =
GetData_month_years(currentReportingPeriod - 1);
for (int j = 0; j < monthYears.Count(); j++)
{
cell = InsertCellInWorksheet(headerCells[cellNo++], 2, worksheetPart);
cell.CellValue = new CellValue(monthYears[j].ToString());
cell.DataType = new EnumValue<CellValues>(CellValues.String);
}
只有A和AA到AH这些单元格中有数据。
我想我是遇到了某种限制,如果是的话,该如何重置?
我看到过一些关于无法读取内容错误的帖子,并且已经阅读了文档,但目前还没有找到任何适用的东西。
希望能得到帮助!
谢谢