If I apply a style that exists in the template spreadsheet that I'm updating the resulting spreadsheet does not reflect that style. Please let me know what I'm doing incorrectly.
Thanks,
Andy
Exmaple code:
static void Main(string[] args)
{
int baseRow = 9;
byte baseCol = 0;
Workbook xl = new Workbook();
xl.Open("Distribution Report Template.xls", Aspose.Cells.FileFormatType.Excel2003);
// New sheet
Worksheet sheet = xl.Worksheets[ xl.Worksheets.AddCopy( "Template" ) ];
sheet.Name = "A";
// Some data
System.Data.DataTable t = new System.Data.DataTable();
t.Columns.Add(new System.Data.DataColumn("Value", System.Type.GetType("System.String")));
t.Columns.Add(new System.Data.DataColumn("Ct", System.Type.GetType("System.Int32")));
t.Columns.Add(new System.Data.DataColumn("Pct", System.Type.GetType("System.Double")));
t.Columns.Add(new System.Data.DataColumn("Last Ct", System.Type.GetType("System.Int32")));
t.Columns.Add(new System.Data.DataColumn("Last Pct", System.Type.GetType("System.Double")));
object[] a = new object[5];
a[0] = "Test";
a[1] = 100;
a[2] = 0.1;
a[3] = 100;
a[4] = 0.1;
t.Rows.Add(a);
Row _row = sheet.Cells.Rows[11];
// Simple Style created in the template opened above.
Style stl1 = xl.Styles["ValueHeader"];
StyleFlag _allFlag = new StyleFlag();
_allFlag.All = true;
_row.ApplyStyle(stl1, _allFlag);
try
{
sheet.Cells.ImportDataTable
( t
, false
, baseRow+1
, baseCol
, false );
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
xl.Save("test.xls");
}
}