【发布时间】:2015-05-22 16:57:43
【问题描述】:
我正在使用 VS2010 C++ 和 Office 2010 创建基于 Excel 模板的报告。 C++ 可以成功打开、插入值并将 xlsx 保存为其他内容,但我希望它也可以保存为 PDF。尽管看到了 VB、C# 和 PowerShell 中的示例,但我仍在努力处理 ExportAsFixedFormat() 函数的 _variant_t 参数。任何人都可以提供示例代码吗? 我的功能外壳:
Excel::_ApplicationPtr pXL;
if (FAILED(pXL.CreateInstance("Excel.Application")))
{
return FALSE;
}
pXL->Workbooks->Open("c:\\tempRep.xlsx");
pXL->PutVisible(0, FALSE);
// Get the active worksheet
Excel::_WorksheetPtr pWksheet = pXL->ActiveSheet;
//... use the spreadsheet
// Save the worksheet
pWksheet->SaveAs("c:\\newRep.xlsx");
pWksheet->ExportAsFixedFormat(??const _variant_t &Filename, ....??)
谢谢,史蒂夫
【问题讨论】:
标签: c++ excel pdf automation export