Percent- number- date- ... cell style

Hi,

How can i set the cell style to percent, number or date for exemple ?

I know that some version of Excel had a limit of style number, if i apply 3 times the same style for 3 differents cells does Excel count only one style or 3 differents styles ?

Thanks

Hi,

Thanks for considering Aspose.

Please check for your reference:

And if you have to apply same formattings to a range of cells, you 'd better create a style object, set its formattings attributes and apply it to those range of cells.

E.g.,
Workbook workbook = new Workbook();
Worksheet sheet1 = workbook.Worksheets[0];
Cells cells = sheet1.Cells;
cells["A1"].PutValue(3537);
//Creating a style object and apply it to some cells.
Style style = workbook.Styles[workbook.Styles.Add()];
style.Custom = "0%";
cells["A1"].Style = style;
cells["A2"].Style = style;
workbook.Save("d:\\test\\stylepercent.xls");
Further reference: `http://www.aspose.com/Wiki/default.aspx/Aspose.Cells/PerformanceTips.html`
Thank you.

Hi,

It seems that if i want to format cell to number, date i need to do a PutValue with the right type.

Exemple :

To format a cell to numeric, i need to apply format style value to 0 AND also do a PutValue of an integer.

My main problem is that i don't know the type of the data to write in the cell, so i handle everything like a string.

It is possible to handle yourself the different cast ?

If i do a PutValue(object), is Aspose.Cells do the cast by itself ?

Thanks

Hi,

I think you may use the following overloaded version of Cell.PutValue() method:

public void PutValue(
string stringValue,
bool isConverted
);

Parameters:

stringValue
Input value
isConverted
True: converted to other data type if appropriate.

Thank you.

Thanks a lot for your answer