Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++;Builder和Excel自动化,从哪里开始? 我想用C++ Builder 2009动态创建和填充Excel电子表格,但我不太确定如何去处理它。搜索web时,我将其范围缩小到使用OLE自动化。此外,我正在寻找一个文档或编程教程,可以让我开始。是否有一个简单的编程教程也能全面解释OLE自动化的概念?_C++_Excel_Automation_C++builder - Fatal编程技术网

C++;Builder和Excel自动化,从哪里开始? 我想用C++ Builder 2009动态创建和填充Excel电子表格,但我不太确定如何去处理它。搜索web时,我将其范围缩小到使用OLE自动化。此外,我正在寻找一个文档或编程教程,可以让我开始。是否有一个简单的编程教程也能全面解释OLE自动化的概念?

C++;Builder和Excel自动化,从哪里开始? 我想用C++ Builder 2009动态创建和填充Excel电子表格,但我不太确定如何去处理它。搜索web时,我将其范围缩小到使用OLE自动化。此外,我正在寻找一个文档或编程教程,可以让我开始。是否有一个简单的编程教程也能全面解释OLE自动化的概念?,c++,excel,automation,c++builder,C++,Excel,Automation,C++builder,要打开excel电子表格: Variant excelApp = Unassigned; //EOleSysError is thrown if GetActiveObject does not succeed. i.e //if Excel is not currently open. try { excelApp = Variant::GetActiveObject("Excel.Application"); } catch(EOleSysError& e) { e

要打开excel电子表格:

Variant excelApp = Unassigned;

//EOleSysError is thrown if GetActiveObject does not succeed. i.e
//if Excel is not currently open.
try
{
    excelApp = Variant::GetActiveObject("Excel.Application");
}
catch(EOleSysError& e)
{
    excelApp = Variant::CreateObject("Excel.Application"); //open excel
}

excelApp.OlePropertySet("ScreenUpdating", true);
要获取当前单元格指针,请执行以下操作:

Variant excelCell = excelSheet.OlePropertyGet("Cells"); 
要向excel中添加值,请执行以下操作:

// create a vararray of 5 elements starting at 0
int bounds[2] = {0, 4};
Variant variantValues = VarArrayCreate(bounds, 1, varVariant);

variantValues.PutElement(5, 0);
variantValues.PutElement(5, 1);
variantValues.PutElement(5, 2);
variantValues.PutElement(5, 3);
variantValues.PutElement(5, 4);

Variant cellRange = excelCell.OlePropertyGet(
    "Range", 
    excelCell.OlePropertyGet("Item", rowindex, columnindex),  // start cell  
    excelCell.OlePropertyGet("Item", rowindex2, columnindex2) // finishing cell   
    );

// place array into excel
cellRange.OlePropertySet(
    "Value", 
    excelApp.OleFunction("Transpose", variantValues)
    );
我希望这能让您开始,您可能需要包括
vcl.h
comobj.hpp