VBA代码转换为C++代码有关问题

fieldset{padding:10px;}

VBA代码转换为C++代码问题遇到一个难题,不知道如何将某些操作Excel的代码转换成C++代码,求高手相助,问题已经在注释中说明。#include <string>using namespace std;void __fastcall TForm1::Button1Click(TObject *Sender){ Variant excel_app = Variant::CreateObject("Excel.Application"); //新建一个工作薄 Variant work_book = excel_app.OlePropertyGet("Workbooks").OleFunction("Add"); Variant work_sheet = work_book.OlePropertyGet("Sheets",1); excel_app.OlePropertySet("Visible",false); Variant chart = excel_app.OlePropertyGet("Charts").OleFunction("Add"); //设置表格类型 chart.OlePropertySet("Type",4); //再设置一次ChartType,不然就成为了数据点拆线图 chart.OlePropertySet("ChartType",4); //设置表格标题,模仿下面的VBA代码,但是无法正确运行 //chart.OlePropertyGet("ChartTitle").OlePropertySet("Text","电压曲线");/* ActiveChart.ChartArea.Select With ActiveChart .HasTitle = True .ChartTitle.Characters.Text = "电压曲线" End With*/ //还有设置X轴坐标格式为小时分钟,设置刻度间隔等如下VBA代码不知道如何转换为C++代码/* Selection.TickLabels.NumberFormatLocal = "h:mm;@" With ActiveChart.Axes(xlCategory) .TickLabelSpacing = 100 .TickMarkSpacing = 5 End With*/ //设置表格数据范围 Variant range = work_sheet.OlePropertyGet("Range","A1:D100"); chart.OleProcedure("SetSourceData",range,2); chart.OleFunction("Location",2,"Sheet1"); //将文件保存在当前路径下 string excel_file_name = ParamStr(0).c_str(); int pos = excel_file_name.rfind(‘\\’,excel_file_name.size()); excel_file_name = excel_file_name.substr(0,pos); excel_file_name = excel_file_name + "\\test.xls"; //保存退出 work_book.OleProcedure("SaveAs",excel_file_name.c_str(),39); //保存表格 39:xls格式 work_book.OleProcedure("Close"); //关闭表格 excel_app.OleFunction("Quit");}——解决方案——————————————————–等专业户老妖——解决方案——————————————————–标记先!!出差回来看!!每一幢房子都有一种不同的颜色,

VBA代码转换为C++代码有关问题

相关文章:

你感兴趣的文章:

标签云: