ExecuteWithRegions
ExecuteWithRegions(string, string, DataTable)
Performs mail merge from a DataTable into the document with mail merge regions.
public static void ExecuteWithRegions(string inputFileName, string outputFileName,
DataTable dataTable)
Parameter | Type | Description |
---|---|---|
inputFileName | String | The input file name. |
outputFileName | String | The output file name. |
dataTable | DataTable | Data source for the mail merge operation. The table must have its TableName property set. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
Examples
Shows how to do mail merge with regions operation from a DataTable.
// There is a several ways to do mail merge with regions operation from a DataTable:
string doc = MyDir + "Mail merge with regions.docx";
DataTable dataTable = new DataTable("MyTable");
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("LastName");
dataTable.Rows.Add(new object[] { "John", "Doe" });
dataTable.Rows.Add(new object[] { "", "" });
dataTable.Rows.Add(new object[] { "Jane", "Doe" });
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataTable.1.docx", dataTable);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataTable.2.docx", SaveFormat.Docx, dataTable);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataTable.3.docx", SaveFormat.Docx, dataTable, new MailMergeOptions() { TrimWhitespaces = true });
See Also
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ExecuteWithRegions(string, string, SaveFormat, DataTable, MailMergeOptions)
Performs mail merge from a DataTable into the document with mail merge regions.
public static void ExecuteWithRegions(string inputFileName, string outputFileName,
SaveFormat saveFormat, DataTable dataTable, MailMergeOptions mailMergeOptions = null)
Parameter | Type | Description |
---|---|---|
inputFileName | String | The input file name. |
outputFileName | String | The output file name. |
saveFormat | SaveFormat | The output’s save format. |
dataTable | DataTable | Table that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored. |
mailMergeOptions | MailMergeOptions | Mail merge options. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
Examples
Shows how to do mail merge with regions operation from a DataTable.
// There is a several ways to do mail merge with regions operation from a DataTable:
string doc = MyDir + "Mail merge with regions.docx";
DataTable dataTable = new DataTable("MyTable");
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("LastName");
dataTable.Rows.Add(new object[] { "John", "Doe" });
dataTable.Rows.Add(new object[] { "", "" });
dataTable.Rows.Add(new object[] { "Jane", "Doe" });
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataTable.1.docx", dataTable);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataTable.2.docx", SaveFormat.Docx, dataTable);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataTable.3.docx", SaveFormat.Docx, dataTable, new MailMergeOptions() { TrimWhitespaces = true });
See Also
- enum SaveFormat
- class MailMergeOptions
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ExecuteWithRegions(string, string, SaveOptions, DataTable, MailMergeOptions)
Performs mail merge from a DataTable into the document with mail merge regions.
public static void ExecuteWithRegions(string inputFileName, string outputFileName,
SaveOptions saveOptions, DataTable dataTable, MailMergeOptions mailMergeOptions = null)
Parameter | Type | Description |
---|---|---|
inputFileName | String | The input file name. |
outputFileName | String | The output file name. |
saveOptions | SaveOptions | The output’s save options. |
dataTable | DataTable | Table that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored. |
mailMergeOptions | MailMergeOptions | Mail merge options. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
See Also
- class SaveOptions
- class MailMergeOptions
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ExecuteWithRegions(Stream, Stream, SaveFormat, DataTable, MailMergeOptions)
Performs a mail merge operation for a single record.
public static void ExecuteWithRegions(Stream inputStream, Stream outputStream,
SaveFormat saveFormat, DataTable dataTable, MailMergeOptions mailMergeOptions = null)
Parameter | Type | Description |
---|---|---|
inputStream | Stream | The input file stream. |
outputStream | Stream | The output file stream. |
saveFormat | SaveFormat | The output’s save format. |
dataTable | DataTable | Table that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored. |
mailMergeOptions | MailMergeOptions | Mail merge options. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
Examples
Shows how to do mail merge with regions operation from a DataTable using documents from the stream.
// There is a several ways to do mail merge with regions operation from a DataTable using documents from the stream:
DataTable dataTable = new DataTable("MyTable");
dataTable.Columns.Add("FirstName");
dataTable.Columns.Add("LastName");
dataTable.Rows.Add(new object[] { "John", "Doe" });
dataTable.Rows.Add(new object[] { "", "" });
dataTable.Rows.Add(new object[] { "Jane", "Doe" });
using (FileStream streamIn = new FileStream(MyDir + "Mail merge.doc", FileMode.Open, FileAccess.Read))
{
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStreamWithRegionsDataTable.1.docx", FileMode.Create, FileAccess.ReadWrite))
MailMerger.ExecuteWithRegions(streamIn, streamOut, SaveFormat.Docx, dataTable);
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStreamWithRegionsDataTable.2.docx", FileMode.Create, FileAccess.ReadWrite))
MailMerger.ExecuteWithRegions(streamIn, streamOut, SaveFormat.Docx, dataTable, new MailMergeOptions() { TrimWhitespaces = true });
}
See Also
- enum SaveFormat
- class MailMergeOptions
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ExecuteWithRegions(Stream, Stream, SaveOptions, DataTable, MailMergeOptions)
Performs a mail merge operation for a single record.
public static void ExecuteWithRegions(Stream inputStream, Stream outputStream,
SaveOptions saveOptions, DataTable dataTable, MailMergeOptions mailMergeOptions = null)
Parameter | Type | Description |
---|---|---|
inputStream | Stream | The input file stream. |
outputStream | Stream | The output file stream. |
saveOptions | SaveOptions | The output’s save options. |
dataTable | DataTable | Table that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored. |
mailMergeOptions | MailMergeOptions | Mail merge options. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
See Also
- class SaveOptions
- class MailMergeOptions
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ExecuteWithRegions(string, string, DataSet)
Performs mail merge from a DataSet into a document with mail merge regions.
public static void ExecuteWithRegions(string inputFileName, string outputFileName, DataSet dataSet)
Parameter | Type | Description |
---|---|---|
inputFileName | String | The input file name. |
outputFileName | String | The output file name. |
dataSet | DataSet | DataSet that contains data to be inserted into mail merge fields. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
Examples
Shows how to do mail merge with regions operation from a DataSet.
// There is a several ways to do mail merge with regions operation from a DataSet:
string doc = MyDir + "Mail merge with regions data set.docx";
DataTable tableCustomers = new DataTable("Customers");
tableCustomers.Columns.Add("CustomerID");
tableCustomers.Columns.Add("CustomerName");
tableCustomers.Rows.Add(new object[] { 1, "John Doe" });
tableCustomers.Rows.Add(new object[] { 2, "Jane Doe" });
DataTable tableOrders = new DataTable("Orders");
tableOrders.Columns.Add("CustomerID");
tableOrders.Columns.Add("ItemName");
tableOrders.Columns.Add("Quantity");
tableOrders.Rows.Add(new object[] { 1, "Hawaiian", 2 });
tableOrders.Rows.Add(new object[] { 2, "Pepperoni", 1 });
tableOrders.Rows.Add(new object[] { 2, "Chicago", 1 });
DataSet dataSet = new DataSet();
dataSet.Tables.Add(tableCustomers);
dataSet.Tables.Add(tableOrders);
dataSet.Relations.Add(tableCustomers.Columns["CustomerID"], tableOrders.Columns["CustomerID"]);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataSet.1.docx", dataSet);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataSet.2.docx", SaveFormat.Docx, dataSet);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataSet.3.docx", SaveFormat.Docx, dataSet, new MailMergeOptions() { TrimWhitespaces = true });
See Also
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ExecuteWithRegions(string, string, SaveFormat, DataSet, MailMergeOptions)
Performs mail merge from a DataSet into the document with mail merge regions.
public static void ExecuteWithRegions(string inputFileName, string outputFileName,
SaveFormat saveFormat, DataSet dataSet, MailMergeOptions mailMergeOptions = null)
Parameter | Type | Description |
---|---|---|
inputFileName | String | The input file name. |
outputFileName | String | The output file name. |
saveFormat | SaveFormat | The output’s save format. |
dataSet | DataSet | DataSet that contains data to be inserted into mail merge fields. |
mailMergeOptions | MailMergeOptions | Mail merge options. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
Examples
Shows how to do mail merge with regions operation from a DataSet.
// There is a several ways to do mail merge with regions operation from a DataSet:
string doc = MyDir + "Mail merge with regions data set.docx";
DataTable tableCustomers = new DataTable("Customers");
tableCustomers.Columns.Add("CustomerID");
tableCustomers.Columns.Add("CustomerName");
tableCustomers.Rows.Add(new object[] { 1, "John Doe" });
tableCustomers.Rows.Add(new object[] { 2, "Jane Doe" });
DataTable tableOrders = new DataTable("Orders");
tableOrders.Columns.Add("CustomerID");
tableOrders.Columns.Add("ItemName");
tableOrders.Columns.Add("Quantity");
tableOrders.Rows.Add(new object[] { 1, "Hawaiian", 2 });
tableOrders.Rows.Add(new object[] { 2, "Pepperoni", 1 });
tableOrders.Rows.Add(new object[] { 2, "Chicago", 1 });
DataSet dataSet = new DataSet();
dataSet.Tables.Add(tableCustomers);
dataSet.Tables.Add(tableOrders);
dataSet.Relations.Add(tableCustomers.Columns["CustomerID"], tableOrders.Columns["CustomerID"]);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataSet.1.docx", dataSet);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataSet.2.docx", SaveFormat.Docx, dataSet);
MailMerger.ExecuteWithRegions(doc, ArtifactsDir + "LowCode.MailMergeWithRegionsDataSet.3.docx", SaveFormat.Docx, dataSet, new MailMergeOptions() { TrimWhitespaces = true });
See Also
- enum SaveFormat
- class MailMergeOptions
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ExecuteWithRegions(string, string, SaveOptions, DataSet, MailMergeOptions)
Performs mail merge from a DataSet into the document with mail merge regions.
public static void ExecuteWithRegions(string inputFileName, string outputFileName,
SaveOptions saveOptions, DataSet dataSet, MailMergeOptions mailMergeOptions = null)
Parameter | Type | Description |
---|---|---|
inputFileName | String | The input file name. |
outputFileName | String | The output file name. |
saveOptions | SaveOptions | The output’s save options. |
dataSet | DataSet | DataSet that contains data to be inserted into mail merge fields. |
mailMergeOptions | MailMergeOptions | Mail merge options. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
See Also
- class SaveOptions
- class MailMergeOptions
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ExecuteWithRegions(Stream, Stream, SaveFormat, DataSet, MailMergeOptions)
Performs mail merge from a DataSet into the document with mail merge regions.
public static void ExecuteWithRegions(Stream inputStream, Stream outputStream,
SaveFormat saveFormat, DataSet dataSet, MailMergeOptions mailMergeOptions = null)
Parameter | Type | Description |
---|---|---|
inputStream | Stream | The input file stream. |
outputStream | Stream | The output file stream. |
saveFormat | SaveFormat | The output’s save format. |
dataSet | DataSet | DataSet that contains data to be inserted into mail merge fields. |
mailMergeOptions | MailMergeOptions | Mail merge options. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
Examples
Shows how to do mail merge with regions operation from a DataSet using documents from the stream.
// There is a several ways to do mail merge with regions operation from a DataSet using documents from the stream:
DataTable tableCustomers = new DataTable("Customers");
tableCustomers.Columns.Add("CustomerID");
tableCustomers.Columns.Add("CustomerName");
tableCustomers.Rows.Add(new object[] { 1, "John Doe" });
tableCustomers.Rows.Add(new object[] { 2, "Jane Doe" });
DataTable tableOrders = new DataTable("Orders");
tableOrders.Columns.Add("CustomerID");
tableOrders.Columns.Add("ItemName");
tableOrders.Columns.Add("Quantity");
tableOrders.Rows.Add(new object[] { 1, "Hawaiian", 2 });
tableOrders.Rows.Add(new object[] { 2, "Pepperoni", 1 });
tableOrders.Rows.Add(new object[] { 2, "Chicago", 1 });
DataSet dataSet = new DataSet();
dataSet.Tables.Add(tableCustomers);
dataSet.Tables.Add(tableOrders);
dataSet.Relations.Add(tableCustomers.Columns["CustomerID"], tableOrders.Columns["CustomerID"]);
using (FileStream streamIn = new FileStream(MyDir + "Mail merge.doc", FileMode.Open, FileAccess.Read))
{
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStreamWithRegionsDataTable.1.docx", FileMode.Create, FileAccess.ReadWrite))
MailMerger.ExecuteWithRegions(streamIn, streamOut, SaveFormat.Docx, dataSet);
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MailMergeStreamWithRegionsDataTable.2.docx", FileMode.Create, FileAccess.ReadWrite))
MailMerger.ExecuteWithRegions(streamIn, streamOut, SaveFormat.Docx, dataSet, new MailMergeOptions() { TrimWhitespaces = true });
}
See Also
- enum SaveFormat
- class MailMergeOptions
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ExecuteWithRegions(Stream, Stream, SaveOptions, DataSet, MailMergeOptions)
Performs mail merge from a DataSet into the document with mail merge regions.
public static void ExecuteWithRegions(Stream inputStream, Stream outputStream,
SaveOptions saveOptions, DataSet dataSet, MailMergeOptions mailMergeOptions = null)
Parameter | Type | Description |
---|---|---|
inputStream | Stream | The input file stream. |
outputStream | Stream | The output file stream. |
saveOptions | SaveOptions | The output’s save options. |
dataSet | DataSet | DataSet that contains data to be inserted into mail merge fields. |
mailMergeOptions | MailMergeOptions | Mail merge options. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
See Also
- class SaveOptions
- class MailMergeOptions
- class MailMerger
- namespace Aspose.Words.LowCode
- assembly Aspose.Words