Our solution provides a powerful platform independent API. Use our Mail merge document API to develop high-level software for Java platform. This is a powerful software solution for merging templates in Word and PDF formats and data from custom data sources and further exporting the result to DOCX, PDF, HTML and other popular formats using Java.
Fast Java library to execute Mail merge with Excel data.
Our Mail Merge SDK allows you to populate a Word template with your data from Excel sheet. Based on our Mail Merge API, you can create your own software solution using Java, which allows you to automate emails from Excel and generate reports with Excel data.
To Mail merge from Excel to Word, simply perform the Mail merge operation in Java and export the result to any supported Word formats.
With our powerful Mail merge API, you can create personalized documents in Java using just a Word Merge template and data from Excel.
How to use Mail merge from Excel:
With our high-fidelity Mail merge API, you can also perform a Mail merge operation with Google Docs. Just download the necessary data in Word and Excel format, make sure that the Word template contains merge fields and perform the Mail merge operation in Java, similar to the algorithm described in the previous section.
To try this powerful Mail merge web tool, load a Word template with special merge fields and data from Excel converted as described above. After running the code, export the result to any format using Java.
The following example shows how to perform a Mail merge operation to generate a Word document in Java:
import com.aspose.words.*;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
Document doc = new Document("Input1.docx");
Workbook workbook = new Workbook("Input2.xlsx");
Worksheet worksheet = workbook.getWorksheets().get(0);
com.aspose.cells.Range dataRange = worksheet.getCells().getMaxDisplayRange();
Object dataTable[][] = worksheet.getCells().exportArray(
0, 0, dataRange.getRowCount(), dataRange.getColumnCount());
doc.getMailMerge().execute(ObjectToDataTable(dataTable));
doc.save("Output.docx");
private static DataTable ObjectToDataTable(Object[][] data) {
DataTable dataTable = new DataTable("CellsTable");
for (int i = 0; i < data[0].length; i++)
dataTable.getColumns().add(data[0][i].toString());
for (int i = 1; i < data.length; i++)
dataTable.getRows().add(data[i]);
return dataTable;
}
We host our Java packages in Maven repositories. 'Aspose.Words for Java' is a common JAR file containing byte-code. Please follow the step-by-step instructions on how to install it to your Java developer environment.
Java SE 7 and more recent Java versions are supported. We also provide a separate package for Java SE 6 in case you are obliged to use this outdated JRE.
Our Java package is cross-platform and runs on all operating systems with JVM implementation, including Microsoft Windows, Linux, macOS, Android and iOS.
For information on optional package dependencies, such as JogAmp JOGL, Harfbuzz font engine, Java Advanced Imaging JAI, please refer to Product Documentation.
You can perform Mail merge operation for other file formats: