Different Ways to Open Files

Opening a File via a Path

Developers can open a Microsoft Excel file using its file path on the local computer by specifying it in the Workbook class constructor. Pass the path in the constructor as a string. Aspose.Cells will automatically detect the file format type.

workbook, _ := NewWorkbook_String("Book1.xlsx")
workbook.Save_String("Book1.pdf")

Opening a File Using a Stream

It is also possible to open an Excel file as a stream. To do so, use an overloaded version of the constructor that takes the Stream object that contains the file.

data, _ := os.ReadFile(filePath)
workbook, _ := NewWorkbook_Stream(data)