PowerPoint slide produced by Spire is unreadable by PowerPoint

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dbrewerton
    New Member
    • Nov 2009
    • 115

    PowerPoint slide produced by Spire is unreadable by PowerPoint

    Hey folks, I have code that is supposed to generate a PowerPoint chart automatically. However, whenever I implement this code, it breaks the slide. No idea why it does this but whatever. So, here is the code to call the slide builder helper:

    Code:
                    SqlCommand sqlcmdLOC = new SqlCommand(sqlQueryLOC, sqlconn);
                    using (SqlDataAdapter da1 = new SqlDataAdapter(sqlcmdLOC))
                    {
                        DataTable dt1 = new DataTable();
                        da1.Fill(dt1);
                        InitChartData(chart1, dt1);
                        sqlconn.Close();
                    }
    That InitChartData(c hart1, dt1) call goes into this routine:

    Code:
            private static void InitChartData(IChart chart1, DataTable dt1)
            {
                //set series name
                ChartSeriesFormatCollection ctf = chart1.Series;
                for (int c = 0; c < dt1.Columns.Count; c++)
                {
                    chart1.ChartData[0, c].Text = dt1.Columns[c].Caption;
                    if (c > 0)
                    {
                        ctf.Append(chart1.ChartData[0, c]);
                    }
                }
                ChartCategoryCollection catg = chart1.Categories;
                for (int r = 0; r < dt1.Rows.Count; r++)
                {
                    //set category
                    catg.Append(chart1.ChartData[r + 1, 0]);
    
                    //set chartData value
                    object[] data = dt1.Rows[r].ItemArray;
    
                    for (int c = 0; c < data.Length; c++)
                    {
                        chart1.ChartData[r + 1, c].Value = data[c];
                    }
                    //set series value
                    for (int i = 0; i < ctf.Count; i++)
                    {
                        chart1.Series[i].Values.Add(chart1.ChartData[r + 1, i + 1]);
                    }
                }
            }
    Attached Files
  • SioSio
    Contributor
    • Dec 2019
    • 272

    #2
    If you have a question about a commercial library, you can get a better answer by asking a question on a dedicated site.

    Comment

    Working...