开发者

Chart Validation

开发者 https://www.devze.com 2023-03-28 03:10 出处:网络
I\'m gonna make a project to convert data and chart to powerpoint file to excel file. but I found some problem here,,

I'm gonna make a project to convert data and chart to powerpoint file to excel file.

but I found some problem here,,

I have make a project to convert chart, with this script

public static void GetChart(string strFilePath, string strDestPath) {

        xl.Application xlApp;
        xl.Workbook xlWorkBook;
        xl.Worksheet xlWorkSheet;
        object misValue = System.Reflection.Missing.Value;

        xlApp = new xl.ApplicationClass();
        xlWorkBo开发者_运维百科ok = xlApp.Workbooks.Open(strFilePath, 0, true, 5,

"", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlWorkSheet = (xl.Worksheet)xlWorkBook.Worksheets.get_Item(1); xl.ChartObjects xlCharts = (xl.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing); xl.ChartObject myChart = (xl.ChartObject)xlCharts.Item(1); xl.Chart chartPage = myChart.Chart;

and then I convert it into an image with this script

GetChart(@"" + textBox1.Text + "", @"d:\" + textBox2.Text + ".jpeg"); label5.Text = @"D:\" + textBox2.Text + ".jpeg";

            pictureBox1.Image = new Bitmap(@"" + label5.Text +

"");

but I think not all of excel file contains a chart, so I try to search a validation about how to detect a chart in every excel file.

How should I do ?


Try checking the number of items in the charts collection, ie xlCharts.Count

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号