打开文件的不同方式
Contents
[
Hide
]
使用Aspose.Cells,可以打开文件以检索数据或使用设计模板加快开发。Aspose.Cells支持打开多种文件格式,如Microsoft Excel(XLS、XLSX、XLSM、XLSB)、CSV或TabDelimited文件。
通过路径打开文件
开发者可以通过在[Workbook]类构造函数中指定本地计算机上的文件路径,打开Microsoft Excel文件。将路径作为字符串传入,Aspose.Cells会自动检测文件格式。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbook, _ := NewWorkbook_String("Book1.xlsx") | |
workbook.Save_String("Book1.pdf") |
通过流打开文件
也可以将 Excel 文件作为流打开。 为此,请使用接受包含文件的 流 对象的构造函数的重载版本。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data, _ := os.ReadFile(filePath) | |
workbook, _ := NewWorkbook_Stream(data) |