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

Free Support Forum - aspose.com

Aspose table styling

Hi ,


I need to fix width of a particular column in a table.

builder.insertCell();
table.setStyleIdentifier(StyleIdentifier.TABLE_GRID);
builder.getFont().setBold(true);
builder.getCellFormat().setWidth(70);

I am trying to use the above code to do the same, but cannot achieve it.
Hi Shilpa,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document
  • Aspose.Words generated output document showing the undesired behavior.
  • Please attach your expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word.
  • Please create a standalone Java application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.

Best regards,

Hi ,


I have to create a table in which i should have the width of first column fixed , rest should be based on the data assigned.

the text should be LEFT aligned.


Can you suggest me how to do this.

Hi Shilpa,


Please try using the following code:

<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table tab = builder.startTable();
builder.insertCell();

CellFormat cellFormat = builder.getCellFormat();
cellFormat.setWidth(72);
builder.writeln(“First”);

builder.insertCell();

cellFormat.setWidth(144);
builder.writeln(“second”);

builder.endRow();

builder.insertCell();

cellFormat = builder.getCellFormat();
cellFormat.setWidth(144);
builder.writeln(“third”);

builder.insertCell();

cellFormat.setWidth(72);
builder.writeln(“Fourth”);

builder.endRow();

builder.endTable();

tab.setAllowAutoFit(true);
tab.autoFit(AutoFitBehavior.FIXED_COLUMN_WIDTHS);

doc.save(“D:\temp\awjava-16.12.0.pdf”);

Best regards,