Open Source C++ Library for Excel Spreadsheet
Read, Write, Edit and Convert Microsoft® Excel Spreadsheet files via Open Source C++ API.
What is OpenXLSX?
OpenXLSX is an open-source C++ library that gives computer programmers the power to read, write, create and modify Excel files as well as data formatting with lesser dependencies. It is a work in progress and aims to provide all the important features for spreadsheet creation and manipulation.
OpenXLSX provides support for several important features, such as Create, open and save spreadsheet files, read or write & modify cell contents, Copy cells and cell ranges, Copy worksheets & many more. OpenXLSX can be built and run on several platforms such as Windows, Linux & Linux.
At A Glance
An overview of OpenXLSX features.
- Create spreadsheets
- Open spreadsheets
- save spreadsheets
- clone worksheet
- Column Widths
- Copy worksheets
- Set Header/footer
- Add filters
- Add styles
- Read cells
- Copy Cells
- Cell ranges
- Merge cells
- Add rows
OpenXLSX only requires C++ runtime.
Getting Started with OpenXLSX
The current stable version is available on CRAN. Please use the following command to install it.
Install OpenXLSX via CRAN
install.packages("openxlsx", dependencies = TRUE)
install.packages("openxlsx", dependencies = TRUE) require(devtools) install_github("ycphs/openxlsx")
C++ API to Create & Modify Spreadsheet Files
The open-source API OpenXLSX enables programmers to generate an Excel spreadsheet from scratch. It also provides support for modifying the existing spreadsheet with ease. To modify an existing file you need to open it and insert the data you want to include in the files. You can create a new worksheet and add it to the empty workbook, add data to it and much more. You can also assign a name to the sheet and can also add content to it. By using the following steps, you can create a Microsoft Excel document in C++
Create Excel Document in C++
- Initialize XLDocument object
- Create document
- Add worksheet in document
- Add text in cell
- Save document
Create Excel Easily - C++
// initialize XLDocument XLDocument doc; // create document doc.create("./Demo01.xlsx"); // add worksheet auto wks = doc.workbook().worksheet("Sheet1"); // add text wks.cell(XLCellReference("A1")).value() =" Hello OpenXLSX!"; // save document doc.save();
Protect Workbook or Worksheet
Evert organizations work hard to collect their required data and don’t want anyone to play with their data. OpenXLSX provides developers with the functionality to preventing people from editing various parts of a workbook. You can protect it by providing a password to limit who can even open it. It is always useful to protect a certain part of a workbook and let the users make changes to other parts when required.
Manage Worksheet Column Widths
The Open-source API OpenXLSX enables software programmers to set worksheet column widths to a specific width or"auto" for automatic width sizing. We can use widths = “auto” in the setColWidths function to auto-widen the column based on the data. You can also use merge cells to create a header for the data frame’s column headers. It also provides features for hiding the columns.