Hi,
1) whats the best way to apply the styles if we are using the import datasource method ?
Well, you may format the cells either before importing data from the datasource to the cells or after you have filled the data to the cells. I think you should create a style object, set its attributes for your desired formattings, then apply style to your desired cells, row, column etc.
http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/approaches-to-format-data-in-cells.html
http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/setting-display-formats-of-numbers-dates.html
http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/dealing-with-font-settings.html
2) Because I am hoping to pre-format the designtime templates - I am am using the designer class -
is this really necessary or it only a benefit if I use smart tags and could equally be using just the workbook class ?
No, WorkbookDesigner class is not necessary here, you may use Workbook class. But if you are using the smart markers, you must use it then.
3) the doco says the designer template should be a .xls format file ? is this critical to retaining formating or something ?
No, your designer class can be in any format i.e. .xls, xlsx, xlt, csv, .xml, txt etc.
4) Because I dont know how long a worksheet will be until populated, the designtime formatting is appied to something like 60 rows in the first worksheet. The issue then is when you go to print it any remaining empty rows are treated as if they contain data - so the user gets lots of blank pages.
I think you can set PageSetup.PrintArea for your requirement.
The only way I can think around this is to apply a row style one row at a time programmatically.
This will be difficult to create as there is quite a bit of formatting applied to get the columns and cells right.
Generally you should do it to apply style to a row / column using Cells.ApplyRowStyle and Cells.ApplyColumnStyle, but you can set the default style for the whole workbook using Workbook.DefaultStyle attribute.
How do I create a row style that contains styles for each column and can it be applied, as I am using the setdatasource method or have I got to loop throught the rows and use putvalue now ?
Sorry, I Could not pick it. Perhaps you want how to apply style to an entire row:
e.g..,
Workbook wb = new Workbook();
Worksheet sheet = wb.Worksheets[0];
Style style1;
StyleFlag flag1;
style1 = wb.Styles[wb.Styles.Add()];
style1.Custom = "yyyy-mm-dd";
flag1 = new StyleFlag();
flag1.NumberFormat = true;
//Apply style to the first column.
sheet.Cells.ApplyColumnStyle(0,style1, flag1);
Style style2;
StyleFlag flag2;
style2 = wb.Styles[wb.Styles.Add()];
style2.Number = 39;
flag2 = new StyleFlag();
flag2.NumberFormat = true;
//Apply style to the 11th row.
sheet.Cells.ApplyRowStyle(10,style2, flag2);
wb.Save("d:\\test\\rowandcolumn_formattings.xls");
ps. what time zone are you in ? do you guys work on the support forum.on the weekend ?
many thanks for all your help.
We are in asia pacific. If there are some queries from our customers, we can work on weekend too.
Thank you.