How to convert excel to word using aspose.cells?

I have a requirement to convert excel template to word. Then using Aspose.Word for JAVA I can merge all word templates (including the converted excel template) to PDF file.

Hi,

Thank you for considering Aspose APIs.

Please note and I am afraid, you cannot convert Excel spreadsheets to Word documents directly via Aspose.Cells APIs. FYI, Aspose.Cells is a spreadsheet management library that manages MS Excel file formats. We have another component i.e., Aspose.Words that manages MS word documents. But, for your requirements, you have to use two APIs, that are; Aspose.Cells & Aspose.Pdf to achieve your goal. The Aspose.Cells APIs will allow you to convert the spreadsheet formats to PDF where Aspose.Pdf APIs can convert PDF to Word document formats

Hope, this helps a bit.

Thank you.

@neerajgautam,

Using newer versions of Aspose.Cells, you can now directly convert an Excel spreadsheet to a Word DOCX, without requiring any intermediate/additional steps or using other APIs. The Workbook.Save method can be used for the task while you may also specify the SaveFormat.Docx enumeration.

  1. For .NET, more details are available on C# EXCEL to WORD - EXCEL to WORD Converter | products.aspose.com page.
  2. For Java, see the details on Java EXCEL to WORD - EXCEL to WORD Converter | products.aspose.com page.

Sample Code

The process involves loading the Excel file into a Workbook object and then calling the Save method.

C# (.NET)

using Aspose.Cells;
using System;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // Load the source Excel file
            Workbook workbook = new Workbook("input.xlsx"); // Replace with your input file path

            // Save the workbook as a DOCX file
            workbook.Save("output.docx", SaveFormat.Docx); // Specify the output file path and format

            Console.WriteLine("Excel file successfully converted to DOCX.");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred: {ex.Message}");
        }
    }
}

This example is detailed in the Aspose knowledge base. Also, see the document: Convert Excel to PDF, Image and other formats|Documentation

Java

import com.aspose.cells.SaveFormat;
import com.aspose.cells.Workbook;

public class ExcelToDocxConverter {
    public static void main(String[] args) throws Exception {
        // Load the source Excel file
        Workbook workbook = new Workbook("input.xlsx"); // Replace with your input file path

        // Save the workbook as a DOCX file
        workbook.save("output.docx", SaveFormat.DOCX); // Specify the output file path and format

        System.out.println("Excel file successfully converted to DOCX.");
    }
}

Further details and options can be found in the Aspose documentation.

We recommend you to download the latest version of Aspose.Cells here:

Please feel free to write us back if you have questions or comments.