테이블 콘텐츠

리뷰 보기

SpreadsheetLocker 안에서 Aspose.Cells.LowCode 액세스 및 편집 능력을 제한하기 위해 암호를 적용함으로써 Excel 파일의 보안을 단순화합니다. 민감한 데이터를 보호하고 .NET 응용 프로그램 내에서 준수 요구 사항을 쉽게 충족시키는 데 이상적입니다. C# Protect Excel 파일을 찾는 개발자를 위해이 도구는 효과적인 솔루션을 제공 합니다.

왜 Excel Spreadsheets를 보호합니까?

  • Secure Sensitive Data: 허가되지 않은 액세스 및 변경을 방지합니다.
  • 데이터의 무결성을 유지하십시오: 정확성과 일관성을 보존하기 위해 완성된 보고서를 닫습니다.
  • Safure Compliance : 비즈니스에 중요한 정보를 제공함으로써 규제 표준을 준수합니다.

SpreadsheetLocker 사용의 이점

  • 쉬운 구현: 최소한의 코딩으로 암호를 적용하거나 제거합니다.
  • 유연한 비밀번호 관리: 문서를 열고 편집하기 위한 별도의 암호.
  • Dynamic Security: 공급 업체를 사용하여 암호를 안전하게 생성하거나 복구합니다.
  • 빠른 통합: 기존 .NET 응용 프로그램과 끊임없이 통신합니다.

원칙

  • 설치 Aspose.Cells.LowCode 를 통해 NuGet :

Install-Package Aspose.Cells.LowCode

  • .NET 6.0 또는 그 이후
  • 수입 필요한 이름 공간:
using Aspose.Cells;
using Aspose.Cells.LowCode;

단계별 보호 가이드

암호 보호를 적용

Excel 파일에 암호를 빠르게 적용하십시오 :

public class SimpleProtectionProvider : AbstractLowCodeProtectionProvider
{
    private readonly string openPwd, writePwd;

    public SimpleProtectionProvider(string openPwd, string writePwd)
    {
        this.openPwd = openPwd;
        this.writePwd = writePwd;
    }

    public override string GetOpenPassword() => openPwd;
    public override string GetWritePassword() => writePwd;
}

var loadOpts = new LowCodeLoadOptions { InputFile = "sensitive.xlsx" };
var saveOpts = new LowCodeSaveOptions { SaveFormat = SaveFormat.Xlsx, OutputFile = "protected.xlsx" };
var provider = new SimpleProtectionProvider("open123", "modify123");
SpreadsheetLocker.Process(loadOpts, saveOpts, provider); 

암호 보호 삭제

이전에 적용된 보호를 제거하십시오 :

var removeProvider = new SimpleProtectionProvider(string.Empty, string.Empty);
SpreadsheetLocker.Process(
  new LowCodeLoadOptions { InputFile = "protected.xlsx" },
  new LowCodeSaveOptions { SaveFormat = SaveFormat.Xlsx, OutputFile = "unlocked.xlsx" },
  removeProvider
);

전체 C# 코드 예제

Excel 암호 보호의 적용 및 제거에 대한 최종 증거:

using System;
using Aspose.Cells.LowCode;

namespace ProtectionExample
{
    public class SimpleProtectionProvider : AbstractLowCodeProtectionProvider
    {
        private readonly string openPwd, writePwd;

        public SimpleProtectionProvider(string openPwd, string writePwd)
        {
            this.openPwd = openPwd;
            this.writePwd = writePwd;
        }

        public override string GetOpenPassword() => openPwd;
        public override string GetWritePassword() => writePwd;
    }

    class Program
    {
        static void Main()
        {
            // Apply Protection
            var loadOpts = new LowCodeLoadOptions { InputFile = "report.xlsx" };
            var saveOpts = new LowCodeSaveOptions { SaveFormat = SaveFormat.Xlsx, OutputFile = "report_protected.xlsx" };
            var provider = new SimpleProtectionProvider("OpenMe", "EditMe");
            SpreadsheetLocker.Process(loadOpts, saveOpts, provider);
            Console.WriteLine("Workbook protected successfully.");

            // Remove Protection
            var removeProvider = new SimpleProtectionProvider(string.Empty, string.Empty);
            SpreadsheetLocker.Process(
            new LowCodeLoadOptions { InputFile = "report_protected.xlsx" },
            new LowCodeSaveOptions { SaveFormat = SaveFormat.Xlsx, OutputFile = "report_unlocked.xlsx" },
            removeProvider
            );
            Console.WriteLine("Protection removed successfully.");
        }
    }
} 

성능 및 보안 팁

  • Batch Protection: 로프 또는 배치 스크립트를 사용하여 여러 파일에 대한 자동 보안.
  • Dynamic Password Retrieval: 구현 안전한 비밀번호 복구 또는 사용자 입력.
  • Audit Logging: 등록 암호 응용 프로그램 및 검토 목적으로 제거 작업.

공통 문제 및 문제 해결

문제해결책
잘못된 암호 오류암호를 조심스럽게 확인하십시오; 그들은 사례 민감합니다.
파일 잠금 문제Excel 파일이 다른 프로그램에서 열리지 않도록 합니다.
지원되지 않은 파일 형식지원되는 파일 형식을 확인하십시오 (XLS, XLSX, XLSTM 및 XLSM).

자주 묻는 질문 (FAQ)

Q1: 개별 잎은 별도로 보호될 수 있습니까? 예, Aspose.Cells’ 전체 API를 사용하십시오 (Worksheet.Protect).

Q2: 사용자는 어떻게 안전하게 암호를 입력할 수 있습니까? 안전한 암호 입력을 위한 사용자 지정 공급자를 만드십시오.

Q3: 보호를 완전히 제거할 수 있습니까? 예, 위에 표시된 바와 같이 빈 암호를 사용하십시오.

관련 자원

More in this category