Create Excel File in Linux

The emergence of automated solutions these days has made spreadsheet automation popular in various industries. The spreadsheet documents are created and manipulated programmatically from within the web or desktop solutions. Accordingly, this article covers how to create Excel XLSX and XLS files on the Linux platform using .NET.

API to Create Excel Files on Linux

To create or edit Excel files on Linux, we will use Aspose.Cells for .NET. It is a feature-rich class library to create, manipulate, and convert Excel files. In order to use the API on Linux, you would need to install the following prerequisites.

If you are new to .NET development on Linux, read how to create a console application on Linux using Visual Studio Code.

For the installation of Aspose.Cells for .NET in your application, you can use the NuGet Package Manager extension for Visual Studio Code. The package of the API is hosted on NuGet.

Create an Excel XLS or XLSX on Linux

The Excel files are termed as the workbooks, which contain one or more worksheets. These worksheets are further divided into cells. Aspose.Cells for .NET uses the same naming convention to work with the Excel files. The following are the steps to create a new Excel file from scratch on Linux.

The following code sample shows how to create an Excel XLSX file on Linux.

Output

Create Excel Files on Linux

Screenshot of the Excel file created using Aspose.Cells

Write Data to an Excel XLSX File on Linux

Aspose.Cells for .NET also allows you to write data to an existing Excel file. For this, you can initialize the Workbook object with the Excel file’s path and manipulate the desired worksheets and cells. The following are the steps to edit an existing Excel file on Linux.

The following code sample shows how to edit and write data to an existing Excel XLSX file on Linux.

Create Charts in Excel XLSX File on Linux

You can also generate graphs and charts to visualize the data in the spreadsheets. Aspose.Cells for .NET provides a complete set of classes to create and manipulate a variety of charts in Excel spreadsheets where each class is used to perform some specific tasks.

The following are the steps to create a chart in Excel file on Linux.

  • Create an Excel file using Workbook class.
  • Add some data to the worksheet by accessing its cells.
  • Add a new chart object to the worksheet using Worksheet.Charts collection by passing the type of chart using the ChartType enumeration.
  • Get the newly created chart from the collection in a Chart object.
  • Specify the cells’ range to provide the data source to the chart object.
  • Save the workbook using Workbook.Save(string, SaveFormat) method.

The following code sample shows how to create a chart in an Excel XLSX file on Linux.

Output

Create chart in Excel on Linux

Chart generated using Aspose.Cells

Learn more about creating charts in Excel worksheets.

Create a Table in Excel XLSX File on Linux

Aspose.Cells for .NET also provides an easy way to create a table from the range of cells in the worksheet. Also, you can add a row for the total in the table. The following are the steps to create a table in an Excel file.

  • Load an Excel workbook or create a new one using Workbook class.
  • Add data to the cells of the worksheet.
  • Add a new ListObject to the worksheet.
  • Set ListObject.ShowTotals property to true.
  • Calculate the total and save the workbook as an Excel file.

The following code sample shows how to create a table in an Excel file on Linux.

Output

Create table in Excel Worksheet on Linux

Learn more about working with tables in Excel worksheets.

Explore Aspose.Cells for .NET

Aspose.Cells for .NET provides a complete package to create and manipulate simple as well as complex Excel files. You can read more about other features of the API using the documentation.

Get a Free License

You can get a temporary license and use Aspose.Cells for .NET without evaluation limitations.

Conclusion

In this article, you have learned how to create Excel files from scratch on Linux. Moreover, you have seen how to add data and create charts and tables in Excel files. This article just covered some basic features of the API. However, you can explore other features by consulting the documentation. In case you would have any queries, you can ask us via our forum.

See Also