This project has moved. For the latest updates, please go here.

problem creating a chart

Jul 15, 2011 at 11:17 AM

Hi, I'm realy not sure with Excel so in dont know how to create a chart or better how excel creates a chart if I choose all the cells in excel and click create chart.

 

This is what i've done:

ws.Cells["A3"].LoadFromDataTable(dt2, true);

            pck.Workbook.Worksheets.Add("Diagramm");         
            var chart = ws.Drawings.AddChart("Balkendiagramm", OfficeOpenXml.Drawing.Chart.eChartType.ColumnClustered); 
            chart.SetPosition(40, 600);

            var serie1 = chart.Series.Add(ws.Cells["D4:D7"], ws.Cells["A4:A7"]);
            var serie2 = chart.Series.Add(ws.Cells["F4:F7"], ws.Cells["A4:A7"]);           

            ws.Column(3).Style.Numberformat.Format = @"[hh]:mm:ss";
            ws.Column(4).Style.Numberformat.Format = @"[hh]:mm:ss";
            ws.Column(5).Style.Numberformat.Format = @"[hh]:mm:ss";
            ws.Column(6).Style.Numberformat.Format = @"[hh]:mm:ss";
            ws.Column(7).Style.Numberformat.Format = @"[hh]:mm:ss";

and it looks like this (left chart is the dynamic generated chart from my code, the right chart is how i want to have it):
http://sv1.imagefire.net/image/c6ad7edeba5e.jpg

thank you!