gpt4 book ai didi

c++ - 在 C++ 或 C# 中打开受密码保护的 Excel 文件提示输入密码,即使我已经传递了密码参数

转载 作者:行者123 更新时间:2023-11-30 03:55:08 25 4
gpt4 key购买 nike

我正在使用 Microsoft.Office.Interop.Excel 从我的 C++/CLI 程序打开受密码保护的 Excel 文件。我提供密码作为第 5 个参数。当我运行我的程序时,Excel 启动并打开我的文件,但它提示输入密码。请注意,该文件受密码保护,而不是工作表。

根据文档,密码应该是对象类型,但作为文字提供它也应该有效吗?

    using namespace System;
using namespace Microsoft::Office::Interop::Excel;
Microsoft::Office::Interop::Excel::Application^ exApp= gcnew Microsoft::Office::Interop::Excel::ApplicationClass();
String^ filename="e:\\test.xls";
Workbook^ wb = exApp->Workbooks->Open(filename, Type::Missing, Type::Missing, Type::Missing, "passw1", Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing);

最佳答案

将只读参数(第 3 个)更改为 true 实际上可以解决问题(除了它以只读方式打开):

exApp->Workbooks->Open(filename, Type::Missing, true, ...

关于c++ - 在 C++ 或 C# 中打开受密码保护的 Excel 文件提示输入密码,即使我已经传递了密码参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29204623/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com