how to set colum width to Auto fit Column Width to AX Exported Excel file

Hi all,

i Have Exported a file from Ax in Excel format .

in the Excel sheet i wrote Code like

ExcelWorksheet.columns.auto fit()

then iam seing only xyz instead ogf xyz@gmail.com

i have to see completed email address…

so,

can any one help me out of these…

Thanks in Advance

Hi Aditya,

Use the below code at the end of your code

sysExcelWorksheetBackOrder.columns().autoFit();

Set the column width to autofit for each added worksheet with backorder lines. Make sure you do this

after you have added all rows in the worksheet,

so it can take into account the width of the largest value in your column.

Thanks & Regards,

Britto John Baskar.A

for example

while select custTable

{

}

sysExcelApplication.displayAlerts(false); // Save the Excel file sysExcelWorkbook.saveAs(fileName); sysExcelWorkBook.comObject().save(); sysExcelWorkBook.saved(true); // Make sure you close the Excel application // Especially if you run the job without showing Excel on the desktop // (sysExcelApplication.visible(false)) sysExcelApplication.quit();

for example

while select custTable

{

sysExcelWorksheet.cells().item(row,1).value(custTable.AccountNum);

while select salesLine join salesTable where salesTable.SalesId == salesLine.SalesId && salesTable.CustAccount == custTable.AccountNum

{

sysExcelWorksheetBackOrder.cells().item(1,2).value(“Item Number”);

sysExcelWorksheetBackOrder.columns().autoFit();

}

sysExcelWorksheet.columns().autoFit();

}

Thanks & Regards,

Britto John Baskar.A

for example

while select custTable

{

sysExcelWorksheet.cells().item(row,1).value(custTable.AccountNum);

while select salesLine join salesTable where salesTable.SalesId == salesLine.SalesId && salesTable.CustAccount == custTable.AccountNum

{

sysExcelWorksheetBackOrder.cells().item(1,2).value(“Item Number”);

sysExcelWorksheetBackOrder.columns().autoFit();

}

sysExcelWorksheet.columns().autoFit();

}

Thanks & Regards,

Britto John Baskar.A