Indent a cell when exporting to Excel

Hello, I am looking for a way to indent a cell when exporting data to Excel in NAV 2013 onwards as follows:





I would like to use the actual indent function built into Excel (e.g. simulate pressing the indent button).

I see the XLApp dot net in the Excel Buffer table looks promising, but I can’t seem to find any documentation on the functions.

you could add some blanks in front of the text instead.

I didnt try but please check whether you have any field like Indentation in table 15.
If yes, depending upon the indentation number you can add blank spaces before the text while exporting.

Thanks Jonathan, I thought about that as well, but I prefer the indent so it will import into Smartsheet properly. It is basically an Excel version of a project plan.

Thanks Mohana, table 15 indeed does have an indentation field. However, I really am looking to call the indent function so it will import into Smartsheet as a project plan with sub tasks.

I mean to say add similar field in your table and while exporting to excel depending upon the field value , add the blank spaces before value.

you could use property indentlevel of the excel range object, setting the indentiation value of table 15.

in table excel buffer (370), which is used for export data to excel, the functions WriteCellValue and WriteCellFormula use .net functions XlWrkShtWriter.SetCellValueText, XlWrkShtWriter.SetCellValueNumber, … and Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.CellDecorator for formatting the cell. indentiation is not supported. you would need your own .net functions.

following blog post could help for customization.…/microsoft-dynamics-nav-2016-export-to.html

Thanks Jonathan, appreciate the info! I was not seeing anything in the existing .net functions so at least I can stop looking! I may end up adding spaces instead.

Hi Don Saito ,
As Jonathan said There is Possibility But you cant Achieve it through Excel Buffer. Bit instead if you use “Interop” Variables then you can use that function i.e InsertIndent Function

Thanks Raja!

Hi Don Saito,

Have you tried Solution ,if Not Try this Its Working …

XlWrkBk := Xlapp.Workbooks.Add(FilePath);

XlWrkSht := XlWrkBk.Worksheets.Item(1);


Let Me Know If You Need Any Help