如何使用C#在asp.net中读取受密码保护的excel文件 [英] How to read Password protected excel file in asp.net with C#

查看:187
本文介绍了如何使用C#在asp.net中读取受密码保护的excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的代码项目团队,

当我读取受密码保护的Excel文件时,我主要使用。发生错误(无法解密文件)请你帮忙解决这个问题。



i可以使用C#代码读取Asp.net中受密码保护的excel文件..





热烈的问候

Rohit Singh

Dear Code Project Team,
i have major use when i read password protected excel file . Error are occur (Could not decrypt file) can you please help about this topic .

i can read Password Protected excel file in Asp.net with C# code..


Warm regards
Rohit Singh

推荐答案

调用Open时需要提供密码



http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.open(v =办公室.14).aspx [ ^ ]
You need to supply the password when calling Open

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.open(v=office.14).aspx[^]


浏览此CP文章





使用Visual Studio .NET自动化MS Excel [ ^ ]
Go through this CP Article


Automating MS Excel Using Visual Studio .NET[^]




你可能想看看这个 .Net Excel组件 [ ^ ]。此C#代码示例演示如何使用它来读取受密码保护的Excel文件:

Hi,
You might want to look at this .Net Excel component[^]. This C# code example shows how to use it to read password protected Excel files:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Elerium.Excel;

namespace ReadPasswordProtection
{
    class Program
    {
        static void Main(string[] args)
        {
            // Read .xls file with password encription.
            ExcelWorkbook wbook = ExcelWorkbook.ReadXLS(@"..\..\..\PasswordExcel.xls", "qwerty");

            // Set new password encription.
            wbook.Options.Password = "asdfgh";

            // Write .xls file.
            wbook.WriteXLS(@"..\..\..\NewPassword.xls");
            //Open specified file in MS Excel.
            System.Diagnostics.Process.Start(@"..\..\..\NewPassword.xls");
        }
    }
}


这篇关于如何使用C#在asp.net中读取受密码保护的excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆