以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 一次性导出电子表格和图表问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=123235) |
-- 作者:HJG_HB950207 -- 发布时间:2018/8/10 12:47:00 -- 一次性导出电子表格和图表问题 窗口 “按科室统计“ 中 有表“分类统计表” 和图表
chart1
导出电子表(多层表头)按如下代码:
Dim dlg As new SaveFileDialog dlg.Filter = "Excel|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.OK Then CurrentTable.SaveExcel(dlg.FileName, CurrentTable.Name) Dim proc As new Process proc.File = dlg.FileName proc.Start End If
单一只导出图表用以下代码十分清晰: Dim dlg As new SaveFileDialog dlg.Filter = "Excel|*.xls;*.xlsx" Dim Ws As MSExcel.WorkSheet =
Wb.WorkSheets(1) ws.name = "test" Dim Chart As WinForm.Chart = Forms("按科室统计").Controls("Chart1") chart.SaveImage("d:\\test.wmf") ws.Shapes.AddPicture("d:\\test.wmf", Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoTrue,0, 0, 100, 80) app.visible = True
请教老师:
如何将以上合二为一,将清晰的图表插入到导出的多层表头电子表中 |
-- 作者:有点甜 -- 发布时间:2018/8/10 14:41:00 -- Dim dlg As new SaveFileDialog dlg.Filter = "Excel|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.OK Then CurrentTable.SaveExcel(dlg.FileName, CurrentTable.Name) Dim App As New MSExcel.Application Dim Wb As MSExcel.Workbook = App.WorkBooks.open(dlg.FileName) Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) ws.name = "test" \'Dim Chart As WinForm.Chart = Forms("按科室统计").Controls("Chart1") \'chart.SaveImage("d:\\test.wmf") ws.Shapes.AddPicture("d:\\test.wmf", Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue,0, 0, 100, 80) app.visible = True End If |
-- 作者:HJG_HB950207 -- 发布时间:2018/8/10 14:55:00 -- 运行有问题 服务器出现意外情况。 (异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT)) |
-- 作者:有点甜 -- 发布时间:2018/8/10 15:25:00 -- 我测试没问题,请认真测试。或者上传文件、代码测试。 |