Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EPPlus: How to add space in cell value in c#

I am currently working in a export to excel of Hierarchical grid using EPPlus. So All child rows should be displayed with padding (space). As shown below:

enter image description here

So as shown in above you can see I have added 4 spaces before Software, QA, Analyst etc...

I have used below code to add space:

worksheet.cells[1, 1].value = "    Software";

But this doesn't seem to be proper way to me. I have tried with \t but that doesn't work.

So is there any better approach I can use here ?

like image 824
confusedDeveloper Avatar asked Jan 04 '23 01:01

confusedDeveloper


1 Answers

What about using Style.Indent like this:

ws.Cells["A4"].Style.Indent = 5;

Here is a reference for how it is done inside the actual excel ui:

http://www.dummies.com/software/microsoft-office/excel/how-to-indent-cell-data-in-excel-2010/

enter image description here

like image 95
Ernie S Avatar answered Jan 18 '23 14:01

Ernie S