C++ API to Convert DOCX to XLS or Online App
Export DOCX to XLS via C++ without using Microsoft® Word or Microsoft® Excel
Why to Convert
In today’s world, data is often stored in multiple formats. For example, documents are stored in DOCX format, while spreadsheets are stored in XLS format. In order to access the data stored in these formats, it is often necessary to convert them into a different format. For example, if you need to access the data stored in a DOCX document, you may need to convert it to XLS format.
How Aspose.Total Helps for DOCX to XLS Conversion
Aspose.Total for C++ is a feature-rich, powerful and easy to use document manipulation and conversion API. It provides APIs for both DOCX to HTML and HTML to XLS conversion. By using Aspose.Words for C++, you can easily export DOCX to HTML. After that, by using Aspose.Cells for C++, you can convert HTML to XLS. Both APIs come under Aspose.Total for C++ package. This makes it easy to include DOCX to XLS conversion feature within your C++ applications.
C++ API to Convert DOCX to XLS
Get Started with C++ File Automation APIs
Install from command line as nuget install Aspose.Total.Cpp
or via Package Manager Console of Visual Studio with Install-Package Aspose.Total.Cpp
.
Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads .
// supports DOC, DOT, DOCX, DOCM, DOTX, DOTM, RTF, WordML, MOBI, ODT, and OTT file formats | |
// load the DOCX. | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"sourceFile.docx"); | |
// save in HTML format | |
doc->Save(u"convertedFile.HTML"); | |
// Load the HTML | |
intrusive_ptr<Aspose::Cells::IWorkbook> wkb = Factory::CreateIWorkbook(u"convertedFile.html"); | |
// supports XLS, XLSX, XLSB, XLSM, XLT, XLT, XLTM, XLAM, CSV, TSV, ODS, DIF, SXC, and FODS file formats. | |
// Save in XLSX format | |
wkb->Save(u"output.xlsx", SaveFormat_Xlsx); |
Access DOCX Document Properties via C++
Aspose.Words for C++ also allows you to access document properties of DOCX file and lets you take an informed decision before the conversion process. To access document properties you can use BuiltInDocumentProperties to obtain built-in properties and CustomDocumentProperties to obtain custom properties. The following code example shows how to enumerate all built-in and custom properties in a document.
// supports DOC, DOT, DOCX, DOCM, DOTX, DOTM, RTF, WordML, MOBI, ODT, and OTT file formats | |
// load the DOCX. | |
System::SharedPtr<Document> doc = System::MakeObject<Document>("sourceFile.docx"); | |
// get built in document properties | |
std::cout << "2. Built-in Properties" << std::endl; | |
for (System::SharedPtr<DocumentProperty> prop : System::IterateOver(doc->get_BuiltInDocumentProperties())) | |
{ | |
std::cout << prop->get_Name().ToUtf8String() << " : " << prop->get_Value()->ToString().ToUtf8String() << std::endl; | |
} | |
// get custom document properties | |
std::cout << "3. Custom Properties" << std::endl; | |
for (System::SharedPtr<DocumentProperty> prop : System::IterateOver(doc->get_CustomDocumentProperties())) | |
{ | |
std::cout << prop->get_Name().ToUtf8String() << " : " << prop->get_Value()->ToString().ToUtf8String() << std::endl; | |
} |
Save XLS File to Stream via C++
After converting DOCX to XLS, Aspose.Cells for C++ enables you to save your document to stream. To save files to a stream, create a MemoryStream or FileStream object and save the file to that stream object by calling the IWorkbook object’s Save method. Specify the desired file format using the SaveFormat enumeration when calling the Save method.
// supports XLS, XLSX, XLSB, XLSM, XLT, XLT, XLTM, XLAM, CSV, TSV, ODS, DIF, SXC, and FODS file formats. | |
// load sample Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook("sampleExcelFile.xlsx"); | |
// create FileStream object | |
intrusive_ptr<FileStream> stream = new FileStream("outputSavingFiletoStream.xlsx", FileMode_CreateNew); | |
// save the Workbook to Stream | |
workbook->Save(stream, SaveFormat_Xlsx); | |
// close stream | |
stream->Close(); |
FAQ
- How can I convert DOCX to XLS Online?To use the above DOCX to XLS converter, simply follow these easy steps. First, add your DOCX file to the converter by either dragging and dropping the file into the white area or clicking inside the area to import the document. Next, click the "Convert" button to initiate the conversion process.
Once the DOCX to XLS conversion is complete, you'll be able to download your converted file instantly with just one click. This makes it incredibly easy to convert your DOCX files to XLS format, and you can do it all without having to install any additional software or plugins. - How long does it take to convert DOCX?When it comes to using the DOCX to XLS converter, the speed of the conversion process will depend largely on the size of your DOCX file. For smaller files, the conversion can be completed in just a few seconds, making it incredibly fast and efficient. However, larger files may take a bit longer to convert.
If you're planning to integrate the DOCX to XLS conversion code into your C++ application, the speed and efficiency of the conversion process will also depend on how well you've optimized your application. By ensuring that your application is optimized for the conversion process, you can help ensure that your DOCX files are converted to XLS format quickly and accurately. - Is it safe to convert DOCX to XLS using free Aspose.Total converter?Of course! When you use the DOCX to XLS converter, you can rest assured that your files are safe and secure. After the conversion is complete, you'll be provided with a download link for your new XLS file. This link will be available instantly and can be used to download the file to your device.
To ensure the safety and privacy of your files, we automatically delete any uploaded files after 24 hours. This means that no one else will have access to your files once the conversion process is complete. Additionally, the DOCX to XLS converter is designed to be safe and secure, so you can trust that your files are being handled with the utmost care. - What browser should I use to convert DOCX?The DOCX to XLS converter is an online tool that can be accessed through any modern web browser, including Google Chrome, Firefox, Opera, and Safari. This makes it incredibly easy to use, as you can simply open the converter in your browser and start converting your DOCX files to XLS format right away.
However, if you're developing a desktop application and need a more robust solution for DOCX conversion, you may want to consider using the Aspose.Total DOCX Conversion API. This powerful API is designed specifically for developers and offers a wide range of features and capabilities for working with DOCX files, including conversion to XLS format.