Hi,
I'm trying out this Aspose.Cells for .NET and one of the important things I need to do is formatting the column. I want to format the columns based from the DataType of my DataTable before I put values into the cells. The reason is so that end-user can add data at the end of the filled rows and the column format would remain the same. for instance I like the column A as Text and when user will key in 01234 - the leading zero will not be truncated. My source code is below... please help.
Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets[0];
wb.Styles.Add();
Style coltext = wb.Styles[0];
coltext.Number = 49;
StyleFlag flagstyle = new StyleFlag();
flagstyle.HorizontalAlignment = true;
flagstyle.VerticalAlignment = true;
flagstyle.ShrinkToFit = true;
flagstyle.Borders = true;
flagstyle.FontColor = true;
int colcnt = 0;
int rowcnt = 0;
int totalrows = tbl.Rows.Count;
foreach (DataColumn col in tbl.Columns)
{
ws.Cells[rowcnt, colcnt].PutValue(col.ColumnName);
switch (col.DataType.ToString())
{
case "System.String":
Column celcol = ws.Cells.Columns[colcnt];
celcol.ApplyStyle(coltext, flagstyle);
break;
}
colcnt += 1;
}