[英]Dynamic sheet creation using Aspose cells in Java?
I am using aspose-cells.jar for Excel export in my application. 我在应用程序中使用aspose-cells.jar进行Excel导出。 I am stuck where I need to dynamically create sheets in the template. 我被困在需要在模板中动态创建图纸的位置。 My original Excel template contains 2 sheets. 我原来的Excel模板包含2张纸。
Depending upon the number of sample data selected these sheets has to be cloned ie Suppose two dates are selected then: 根据所选样本数据的数量,必须克隆这些工作表,即假设选择了两个日期,然后:
And 和
You can use the Worksheets.addCopy method to clone an existing worksheet. 您可以使用Worksheets.addCopy方法来克隆现有工作表。
// Open the workbook
Workbook book = new Workbook(srcDoc);
boolean bSomeCondition = true;
// If some condition is true e.g. dates
if (bSomeCondition)
{
// Copy first worksheet
book.getWorksheets().addCopy("Sheet1");
// Copy the second worksheet
book.getWorksheets().addCopy("Sheet2");
}
// Save the workbook
book.save(dstDoc);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.