Hi,
my value is a TimeSpan and it is set to 0:0:0,5
Here is the style which is being used hh:mm:ss,0
When I open sheet ...the cell has following format 00:00:00.5000000
The style is not being used or am I doing something wrong?
Regards
Rale
Hi,
my value is a TimeSpan and it is set to 0:0:0,5
Here is the style which is being used hh:mm:ss,0
When I open sheet ...the cell has following format 00:00:00.5000000
The style is not being used or am I doing something wrong?
Regards
Rale
Hi Rale,
Thank you for considering Aspose.
Well, I tried to set your mentioned style (hh:mm:ss,0) using MS Excel but MS Excel does not allows to set this style. I tried both MS Excel 2003 and MS Excel 2007. Please create a template file manually in MS Excel and set such style. Post that file here and we will check it soon. Also, please share your sample code to reproduce the issue (for setting the style using Aspose), we will check it soon.
Thank You & Best Regards,
Hi
Please see attached file with style examples
Regards
Rale
Use this example
Workbook wb = new Workbook();
wb.Worksheets.Clear();
Worksheet ws = wb.Worksheets.Add("New");
Style style = wb.Styles[wb.Styles.Add()];
style.Name = "TimeStyle";
style.Custom = "hh:mm:ss.0";
ws.Cells[1, 1].PutValue(new TimeSpan(0, 0, 0, 0, 500));
ws.Cells[1, 1].SetStyle(style);
wb.Save(@"Result.xlsx", FileFormatType.Excel2007Xlsx);
Hi,
Thank you for considering Aspose.
We have found your mentioned issue after an initial test. We will look into it and get back to you soon. Your issue has been registered in our issue tracking system with issue id CELLSNET-12310.
Thank You & Best Regards,
Hi,
Thank you for considering Aspose.
To further update you, we do not support TimeSpan in Cell.PutValue() method, so please use DateTime as the cell value and modify your code as below and check if it fits your need.
Workbook wb = new Workbook();
wb.Worksheets.Clear();
Worksheet ws = wb.Worksheets.Add("New");
Style style = wb.Styles[wb.Styles.Add()];
style.Name = "TimeStyle";
style.Custom = "hh:mm:ss.0";
DateTime time = DateTime.Now;
ws.Cells[0, 0].PutValue(time);
ws.Cells[0, 0].SetStyle(style);
TimeSpan span = new TimeSpan(0, 0, 0, 0, 500);
time = time + span;
ws.Cells[1, 1].PutValue(time);
ws.Cells[1, 1].SetStyle(style);
ws.AutoFitColumns();
wb.Save(@"C:\dest.xls");
Thank You & Best Regards,
But wait. There is support of TimeSpan. Please try code sample below. It is the millisecond that not supported?
Workbook wb = new Workbook();
wb.Worksheets.Clear();
Worksheet ws = wb.Worksheets.Add("New");
Style style = wb.Styles[wb.Styles.Add()];
style.Name = "TimeStyle";
style.Custom = "hh:mm:ss";
TimeSpan value = new TimeSpan(0, 0, 1, 0);
ws.Cells[1, 1].PutValue(value);
ws.Cells[1, 1].SetStyle(style);
wb.Save(@"Result.xlsx", FileFormatType.Excel2007Xlsx);
Hi,
Thank you for the feedback.
We will further look into your issue and get back to you soon.
Thank You & Best Regards,
Hi,
Thank you for considering Aspose.
We do not support TimeSpan in Cell.PutValue() method. If you call Cell.PutValue(TimeSpan) ,we just simply put the string value of TimeSpan to the cell. Please try the following codes and check the result in MS Excel. The number format does not effect in the Cell "B2” which means the value of the cell “B2” is a string (as cell A2 contains value true).
Workbook wb = new Workbook();
wb.Worksheets.Clear();
Worksheet ws = wb.Worksheets.Add("New");
Style style = wb.Styles[wb.Styles.Add()];
style.Name = "TimeStyle";
style.Custom = "yyyy-mm-dd";
//You may also check this style as per your requirement
//style.Custom = "hh:mm:ss";
TimeSpan value = new TimeSpan(0, 0, 1, 0);
ws.Cells["B2"].PutValue(value);
ws.Cells["B2"].SetStyle(style);
ws.Cells["B3"].PutValue(DateTime.Now);
ws.Cells["B3"].SetStyle(style);
ws.Cells["A2"].Formula = "=ISTEXT(B2)";
ws.Cells["A3"].Formula = "=ISTEXT(B3)";
wb.Save(@"C:\PDF\Result.xlsx", FileFormatType.Excel2007Xlsx);
Thank You & Best Regards,