繁体   English   中英

将两个SLDocument合并到一个SLDocument

[英]Merge two SLDocuments to one SLDocument

我正在使用SpreadsheetLight创建2个单独的电子表格。 其中一个带有图表,但是两个都只有一个工作表。

我正在尝试将这两张表合并为一个包含两个工作表的电子表格。 每个单独的工作表都应复制到最终文件的一个工作表中。

我只找到了复制细胞的方法,而没有找到整个文档的方法。 但是这种方式不是一种选择,因为我也需要图表。

提前致谢

看来您无法复制图表,所以...保留图表,复制另一张纸并重命名结果文件:

SLDocument sheetDoc = new SLDocument("ChartSheet.xlsx"); //existing
SLDocument origDoc = new SLDocument("DataSheet.xlsx") //existing
sheetDoc.AddWorksheet("SecondSheet");
//loop to copy the needed information (whole sheet in this case):
    sheetDoc.SetCellValue("A1", origDoc.GetCellValueAsString("A1"));
    sheetDoc.SetCellValue("A2", origDoc.GetCellValueAsString("A2"));
    ...
//end loop
sheetDoc.SaveAs("FinalSheet.xlsx");

希望这能使您步入正轨

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM