We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Coying first table style and creaingone after the other and filling it

Hi,
I am using Aspose to create word document.
I have a doc file where I have the fixed format, there I use to fill the data and it works great.
In the existing I was filling the existing table with one header.
Now my requirement is to create number of tables one after the other as shown in sample.doc
The one which works fine is dispatch.doc with the code below.
Now how do I create no of tables one after the other.
The style and font of all the tables should be like the first sample table in dispatch.doc
The code I used to fill Dispatch.doc is below and works great.
Many Thanks,

DataSet dataSet = new DataSet();
Basket objBasket=new Basket(HttpContext.Current.User.Identity.Name);
clsAdmin objAdmin = new clsAdmin();
DataSet ds = objAdmin.getAddressBankDetail();
DataTable dtAdd = new DataTable();
dtAdd = ds.Tables[0].Copy();
dtAdd.TableName = "getAddressBankDetail";
//Populate tables and add to the dataset.
dataSet.Tables.Add(objBasket.getOrderDetailsDT(Convert.ToInt32(Request["id"].ToString())));
dataSet.Tables.Add(objBasket.listInvoiceItemsDT(Convert.ToInt32(Request["id"].ToString())));
dataSet.Tables.Add(objBasket.listProformaInvoiceTotalsDT(Convert.ToInt32(Request["id"].ToString())));
dataSet.Tables.Add(dtAdd);
//The document should have mail merge regions designated with 
//MERGEFIELD TableStart:MyTableName and TableEnd:MyTableName.
string license.File = MapPath("") + "\\aspose.words.lic";
Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense(licenseFile);
//Word.SetLicense(licenseFile, this);
Aspose.Words.Document doc = OpenDoc();
doc.MailMerge.ExecuteWithRegions(dataSet);

Hi
Thanks for your inquiry. I think that you can achieve this by performing mail merge several times and building up a resulting document from several documents or fragments. The Product Catalog and Sales Invoice samples in the demo project supplied with Aspose.Words demonstrate the suggested techniques.
Best regards.

Thanks for your reply.
Yes, I want something like Product Catalog or Sales Invoice from URL
https://demos.aspose.com/
You do not have sample code for this in your site to help us more in this context.
Thanks again

Hi
Thanks for your inquiry. Sample codes are provided with Aspose.Words class library. After installing Aspose.Words on your PC you can find sample codes in the following folder:
C:\Program Files\Aspose\Aspose.Words\Demos
Best regards.

Thanks, I have seen it now.

Let me go through it. Will come back to you soon
Thanks again for your co-operation

Hi,
Thanks for your help.
I have tried the way Product Catalog works. And It works for me.
I have created word doc file for Order lines and then merged to the orignal doc or destination doc
It is adding the word doc in new file in the destination doc file.
I wish to add doc files one after the other giving some gap.

Also, I wish to add those doc files at particular location in the destination document.
Here is my code below.
Thanks

private Aspose.Words.Document CreateInvoiceFromDataSet()
{
    clsAdmin objAdmin = new clsAdmin();

    DataSet dataSet = objAdmin.getAddressBankDetail();

    DataSet dataSetOrderLines = objBasket.getOrderDetailsDT(Convert.ToInt32(Request["id"].ToString()));
    DataSet dataSetOrderLines2 = objBasket.getOrderDetailsDT(Convert.ToInt32(Request["id"].ToString()));

    //The document should have mail merge regions designated with 
    //MERGEFIELD TableStart:MyTableName and TableEnd:MyTableName.
    string licenseFile = MapPath("") + "\\aspose.words.lic";
    Aspose.Words.License license = new Aspose.Words.License();
    license.SetLicense(licenseFile);
    //Word.SetLicense(licenseFile, this);
    Aspose.Words.Document doc = OpenDoc("quotation.doc");
    Aspose.Words.Document OrderLinesdoc = OpenDoc("quotationDetail.doc");
    Aspose.Words.Document OrderLinesdoc2 = OpenDoc("quotationDetail.doc");
    doc.MailMerge.ExecuteWithRegions(dataSet);

    OrderLinesdoc.MailMerge.ExecuteWithRegions(dataSetOrderLines);
    OrderLinesdoc2.MailMerge.ExecuteWithRegions(dataSetOrderLines2);
    AppendDoc(doc, OrderLinesdoc);
    AppendDoc(doc, OrderLinesdoc2);
    return doc;
}
private void AppendDoc(Document dstDoc, Document srcDoc)
{
    for (int i = 0; i < srcDoc.Sections.Count; i++)
    {
        //First need to import the section into the destination document,
        //this translates any document specific lists or styles.
        Section section = (Section)dstDoc.ImportNode(srcDoc.Sections[i], true);
        dstDoc.Sections.Add(section);
    }
}

Hi
Thanks for your inquiry. I think that you should use InsertDocument method instead AppendDocument. You can find code example here:
https://docs.aspose.com/words/java/insert-and-append-documents/
I think that you can insert the document after some bookmark in your main document.
Best regards.