By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,583 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,583 IT Pros & Developers. It's quick & easy.

PowerPoint slide produced by Spire is unreadable by PowerPoint

dbrewerton
100+
P: 115
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:

Expand|Select|Wrap|Line Numbers
  1.                 SqlCommand sqlcmdLOC = new SqlCommand(sqlQueryLOC, sqlconn);
  2.                 using (SqlDataAdapter da1 = new SqlDataAdapter(sqlcmdLOC))
  3.                 {
  4.                     DataTable dt1 = new DataTable();
  5.                     da1.Fill(dt1);
  6.                     InitChartData(chart1, dt1);
  7.                     sqlconn.Close();
  8.                 }
  9.  
That InitChartData(chart1, dt1) call goes into this routine:

Expand|Select|Wrap|Line Numbers
  1.         private static void InitChartData(IChart chart1, DataTable dt1)
  2.         {
  3.             //set series name
  4.             ChartSeriesFormatCollection ctf = chart1.Series;
  5.             for (int c = 0; c < dt1.Columns.Count; c++)
  6.             {
  7.                 chart1.ChartData[0, c].Text = dt1.Columns[c].Caption;
  8.                 if (c > 0)
  9.                 {
  10.                     ctf.Append(chart1.ChartData[0, c]);
  11.                 }
  12.             }
  13.             ChartCategoryCollection catg = chart1.Categories;
  14.             for (int r = 0; r < dt1.Rows.Count; r++)
  15.             {
  16.                 //set category
  17.                 catg.Append(chart1.ChartData[r + 1, 0]);
  18.  
  19.                 //set chartData value
  20.                 object[] data = dt1.Rows[r].ItemArray;
  21.  
  22.                 for (int c = 0; c < data.Length; c++)
  23.                 {
  24.                     chart1.ChartData[r + 1, c].Value = data[c];
  25.                 }
  26.                 //set series value
  27.                 for (int i = 0; i < ctf.Count; i++)
  28.                 {
  29.                     chart1.Series[i].Values.Add(chart1.ChartData[r + 1, i + 1]);
  30.                 }
  31.             }
  32.         }
  33.  
Attached Files
File Type: pptx slide_1_15_2020-19-16-58.pptx (121.0 KB, 15 views)
Jan 15 '20 #1
Share this Question
Share on Google+
1 Reply


100+
P: 110
If you have a question about a commercial library, you can get a better answer by asking a question on a dedicated site.
https://www.e-iceblue.com/forum/
Jan 16 '20 #2

Post your reply

Sign in to post your reply or Sign up for a free account.