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

Free Support Forum - aspose.com

Formatting - Table- Row- Cell

I am new to ASPOSE and I am trying to dynamically create/amend documents. The documents will be created from templates and will be amended by a batch file, so there will be no user interaction. Because of this, sections will not be used (we have over 250 templates and section info would have to be stored for each detailing section number and it’s content).
The batch file will retrieve the templates and will update form object placeholders with data. The name and type of placeholder will be passed to the batch file depending on the requirement.
My problem is this:
At the end of the document I add data in the form of a table. I have successfully created the table using the “startTable”, “InsertCell” methods (as the documentation details for table creation). However, now I am trying to format the cells without success. The documentation details to format tables by creating a table from a section and adding formatting this way:

Table table = new Table(sec1);
table.setDefaultCellBorder(new BorderInfo(BorderSide.All, 0.1F));

Because the document will not have sections I cannot create the table from any section on the document. Is there any way I can apply formatting when either creating the table (using startTable()) or when inserting the cell (InsertCell()).
I have tried using CellFormat but cannot get this to work (and I am not sure I am using this correctly).
Any help would be greatly appreciated.

Thanks for your request. Please see the following link to learn how to insert Table into the document:
If you need to define formatting of cells before building table, you can use DocumentBuilder.CellFormat. For example, see the following code:

// Create Document and DocumentBuilder
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// specify formating of cells
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
builder.CellFormat.Borders.LineWidth = 2;
builder.CellFormat.Borders.Color = Color.Red;
builder.CellFormat.Width = 100;
// Build simple table
for (int i = 0; i < 5; i++)
    for (int j = 0; j < 5; j++)
// Save document

Hope this helps.
Best regards.

thanks very much. I’ll give that a try.