Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
To open a file using Aspose.Cells Java in Python, simply invoke the openFile() method of the Workbook class and specify the second document to append at the end.
Python Code
fileFormatType = self.FileFormatType
# 1. Opening from path
# Creating a Workbook object with an Excel file path
workbook1 = self.Workbook(self.dataDir + "Book1.xls")
print "Workbook opened using path successfully.";
# 2. Opening workbook from stream
# Create a Stream object
fstream = self.FileInputStream(self.dataDir + "Book2.xls")
# Creating a Workbook object with the stream object
workbook2 = self.Workbook(fstream)
fstream.close()
print ("Workbook opened using stream successfully.");
# 3.
# Opening Microsoft Excel 97 Files
# Creating an EXCEL_97_TO_2003 LoadOptions object
loadOptions1 = self.LoadOptions(fileFormatType.EXCEL_97_TO_2003)
# Creating a Workbook object with Excel 97 file path and the LoadOptions object
workbook3 = self.Workbook(self.dataDir + "Book_Excel97_2003.xls", loadOptions1)
# Print message
print("Excel 97 Workbook opened successfully.");
# 4.
# Opening Microsoft Excel 2007 XLSX Files
# Creating an XLSX LoadOptions object
loadOptions2 = self.LoadOptions(fileFormatType.XLSX)
# Creating a Workbook object with 2007 XLSX file path and the LoadOptions object
workbook4 = self.Workbook(self.dataDir + "Book_Excel2007.xlsx", loadOptions2)
# Print message
print ("Excel 2007 Workbook opened successfully.")
# 5.
# Opening SpreadsheetML Files
# Creating an EXCEL_2003_XML LoadOptions object
loadOptions3 = self.LoadOptions(fileFormatType.EXCEL_2003_XML)
# Creating a Workbook object with SpreadsheetML file path and the LoadOptions object
workbook5 = self.Workbook(self.dataDir + "Book3.xml", loadOptions3)
# Print message
print ("SpreadsheetML format workbook has been opened successfully.");
# 6.
# Opening CSV Files
# Creating a CSV LoadOptions object
loadOptions4 = self.LoadOptions(fileFormatType.CSV)
# Creating a Workbook object with CSV file path and the LoadOptions object
workbook6 = self.Workbook(self.dataDir + "Book_CSV.csv", loadOptions4)
# Print message
print ("CSV format workbook has been opened successfully.")
# 7.
# Opening Tab Delimited Files
# Creating a TAB_DELIMITED LoadOptions object
loadOptions5 = self.LoadOptions(fileFormatType.TAB_DELIMITED);
# Creating a Workbook object with Tab Delimited text file path and the LoadOptions object
workbook7 = self.Workbook(self.dataDir + "Book1TabDelimited.txt", loadOptions5)
# Print message
print("<br />");
print ("Tab Delimited workbook has been opened successfully.");
# 8.
# Opening Encrypted Excel Files
# Creating an EXCEL_97_TO_2003 LoadOptions object
loadOptions6 = self.LoadOptions(fileFormatType.EXCEL_97_TO_2003)
# Setting the password for the encrypted Excel file
loadOptions6.setPassword("1234")
# Creating a Workbook object with file path and the LoadOptions object
workbook8 = self.Workbook(self.dataDir + "encryptedBook.xls", loadOptions6)
# Print message
print("<br />");
print ("Encrypted workbook has been opened successfully.");Download Opening File (Aspose.Cells) from any of the below mentioned social coding sites:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.