【发布时间】:2012-08-16 15:19:33
【问题描述】:
我创建了一个项目,该项目读取不同的文件,然后使用电子表格将其放入不同的工作表中。 我使用了 Open office calc 电子表格,因此使用以下代码打开一个空白文件:
public XSpreadsheet getSpreadsheet(int nIndex, XComponent xComp)
{
XSpreadsheets xSheets = ((XSpreadsheetDocument)xComp).getSheets();
XIndexAccess xSheetsIA = (XIndexAccess)xSheets;
XSpreadsheet xSheet =(XSpreadsheet)xSheetsIA.getByIndex(nIndex).Value;
return xSheet;
}
我把一张纸叫作这样使用:
XSpreadsheet newSheet = getSpreadsheet(sheetIndex, xComp);
xComp 在哪里:
string filePathway = @"file:///c:/temp/blank.ods";
PropertyValue[] propVals = new PropertyValue[0];
XComponent oCalcuDoc = oDesktop.loadComponentFromURL(filePathway, "_blank", 0, propVals);
但是我的问题是文件 blank.ods 需要设置为在应用程序运行之前已插入电子表格所需的工作表数量。这并不理想,因为所需的纸张数量并不总是已知的。有没有办法从我的应用程序中插入工作表?
任何帮助将不胜感激。
【问题讨论】:
标签: c# openoffice-calc