图表验证
我要做一个项目,将数据和图表转换为 powerpoint 文件到 Excel 文件。
但我在这里发现了一些问题,
我用这个脚本做了一个转换图表的项目
公共静态无效GetChart(字符串strFilePath,字符串strDestPath) {
xl.Application xlApp; xl.Workbook xlWorkBook; xl.Worksheet xlWorkSheet; 对象misValue = System.Reflection.Missing.Value; xlApp = new xl.ApplicationClass(); xlWorkBook = xlApp.Workbooks.Open(strFilePath, 0, true, 5,
“”,“”,正确, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", 假, 假, 0, 真, 1, 0); xl工作表 = (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;
然后我用这个脚本将它转换成图像
GetChart(@"" + textBox1.Text + "", @"d:\" + textBox2.Text + ".jpeg"); label5.Text = @"D:\" + textBox2.Text + ".jpeg";
pictureBox1.Image = new Bitmap(@"" + label5.Text +
"");
但我认为并非所有 Excel 文件都包含图表,因此我尝试搜索有关如何在每个 Excel 文件中检测图表的验证。
我该怎么办?
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(); xlWorkBook = 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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试检查图表集合中的项目数,即 xlCharts.Count
Try checking the number of items in the charts collection, ie xlCharts.Count