在 Jython 中使用工作表索引删除工作表
Contents
[
Hide
]
Aspose.Cells - 使用工作表索引删除工作表
使用附加文档Aspose.Cells Java 对于 Jython.在这里您可以看到示例代码。
Jython代码
from aspose-cells import Settings
from com.aspose.cells import Workbook
from java.io import FileInputStream;
class RemovingWorksheetsusingSheetIndex:
def __init__(self):
dataDir = Settings.dataDir + 'WorkingWithWorksheets/RemovingWorksheetsusingSheetIndex/'
fstream=FileInputStream(dataDir + "Book1.xls");
#Instantiating a Workbook object with the stream
workbook = Workbook(fstream)
#Removing a worksheet using its sheet index
workbook.getWorksheets().removeAt(0)
#Saving the Excel file
workbook.save(dataDir + "book.out.xls")
#Closing the file stream to free all resources
fstream.close()
#Print Message
print "Sheet removed successfully."
if __name__ == '__main__':
RemovingWorksheetsusingSheetIndex()
下载运行代码
下载**附加文件 (Aspose.Cells)**来自以下任何社交编码网站: