Hi
I am having problems setting category axis min and max values.
Values are DateTime type. Should it be converted to number before setting value?
BR
Rale
Hi
I am having problems setting category axis min and max values.
Values are DateTime type. Should it be converted to number before setting value?
BR
Rale
Workbook wb = new Workbook();
wb.Worksheets.Clear();
Worksheet ws = wb.Worksheets.Add("New");
Style style = wb.Styles[wb.Styles.Add()];
style.Name = "DateTimeStyle";
style.Custom = "dd-mm hh:mm:ss";
DateTime dt = DateTime.Now;
ws.Cells[24, 2].PutValue(dt.AddHours(1));
ws.Cells[24, 2].SetStyle(style);
ws.Cells[25, 2].PutValue(dt.AddHours(2));
ws.Cells[25, 2].SetStyle(style);
ws.Cells[26, 2].PutValue(dt.AddHours(3));
ws.Cells[26, 2].SetStyle(style);
ws.Cells[27, 2].PutValue(dt.AddHours(4));
ws.Cells[27, 2].SetStyle(style);
ws.Cells[28, 2].PutValue(dt.AddHours(5));
ws.Cells[28, 2].SetStyle(style);
ws.Cells[29, 2].PutValue(dt.AddHours(6));
ws.Cells[29, 2].SetStyle(style);
ws.Cells[24, 3].PutValue(4);
ws.Cells[25, 3].PutValue(9);
ws.Cells[26, 3].PutValue(13);
ws.Cells[27, 3].PutValue(16);
ws.Cells[28, 3].PutValue(3);
ws.Cells[29, 3].PutValue(7);
Chart chart = ws.Charts[ws.Charts.Add(ChartType.ScatterConnectedByLinesWithoutDataMarker, 1, 1, 22, 12)];
chart.CategoryAxis.TickLabels.NumberFormat = "dd-mm hh:mm;@";
chart.CategoryAxis.TickLabels.Rotation = 45;
chart.CategoryAxis.TickLabels.Font.Size = 8;
chart.Legend.Position = LegendPositionType.Bottom;
chart.ValueAxis.TickLabels.NumberFormat = "0";
chart.ValueAxis.MinValue = 0;
chart.ValueAxis.MaxValue = 20;
chart.Placement = PlacementType.Move;
chart.Title.Text = "Data";
chart.ValueAxis.Title.Text = "unit";
chart.CategoryAxis.MinValue = dt;
chart.CategoryAxis.MaxValue = dt.AddHours(6);
ASeries aSerie = chart.NSeries[chart.NSeries.Add(String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "D", 24, 29), true)];
aSerie.XValues = String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "C", 24, 29);
aSerie.Name = "Date";
wb.Save(@"Result.xlsx", FileFormatType.Excel2007Xlsx);
Hi,
Thanks for providing us sample code.
If I save the xls file it works fine and the file is opened fine into MS Excel. But if I create xlsx file using your code, MS Excel prompt an error opening the generated file into it. We will look into your issue soon. Your issue has been logged into our issue tracking system with an issue id: CELLSNET-12312.
Thank you.
Hi Amjad
the xls file is to show that format can be used in excel and code is to show that same format is not applied to cell.
Thanks & Regards
Rale
Hi,
Please try the attached version. We have fixed the issue “if creating xlsx file using your code, MS Excel prompts an error opening the generated file into it”.
We are not clear if you get any issue about xls file, could you post a template file here to show the effect you need in case you have any issue with xls format.
Thank you
This helps. Template file is ok. No issues there. The only issue was setting min and max values on category axis and this fix resolves it.
Thanks
The issues you have found earlier (filed as 12312) have been fixed in this update.
The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan