在Jython中向新的Excel文件添加工作表
Contents
[
Hide
]
Aspose.Cells - 向新的Excel文件添加工作表
使用Aspose.Cells Java for Jython进行附加文档。这里可以看到示例代码。
Jython 代码
from aspose-cells import Settings
from com.aspose.cells import Workbook
from com.aspose.cells import SaveFormat
class AddingWorksheetstoNewExcelFile:
def __init__(self):
dataDir = Settings.dataDir + 'WorkingWithWorksheets/AddingWorksheetstoNewExcelFile/'
workbook = Workbook(dataDir + "Book1.xls")
#Adding a new worksheet to the Workbook object
worksheets = workbook.getWorksheets()
sheetIndex = worksheets.add()
worksheet = worksheets.get(sheetIndex)
#Setting the name of the newly added worksheet
worksheet.setName("My Worksheet")
#Saving the Excel file
workbook.save(dataDir + "book.out.xls")
#Print Message
print "Sheet added successfully."
if __name__ == '__main__':
AddingWorksheetstoNewExcelFile()
下载运行代码
从以下任何社交编码网站下载Append Documents (Aspose.Cells)