Skydda och avskydda arbetsboksstrukturen med C++
Contents
[
Hide
]
För att förhindra att andra användare ser dolda kalkylblad, lägger till, flyttar, tar bort eller gömmer kalkylbladen, och döper om kalkylbladen, kan du skydda strukturen för din Excel-arbetsbok med ett lösenord.
Skydda och avskydda arbetsboksstrukturen i MS Excel
- Klicka på Granska > Skydda arbetsbok.
- Ange ett lösenord i Lösenordsrutan.
- Välj OK, ange lösenordet igen för att bekräfta det, och välj sedan OK igen.
Skydda arbetsboksens struktur med Aspose.Cells for C++
Bara behöver följande enkla koder för att implementera skydd av arbetsbokens struktur för Excel-filer.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Create a new workbook
Workbook workbook;
// Protect workbook structure with a password
workbook.Protect(ProtectionType::Structure, u"password");
// Save the workbook to a file
workbook.Save(u"Book1.xlsx");
std::cout << "Workbook created and protected successfully!" << std::endl;
Aspose::Cells::Cleanup();
}
Avskydda arbetsboksstrukturen med Aspose.Cells for C++
Det är enkelt att avskydda arbetsbokens struktur med Aspose.Cells API.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Open an Excel file which workbook structure is protected.
U16String inputFilePath = u"Book1.xlsx";
Workbook workbook(inputFilePath);
// Unprotect workbook structure.
workbook.Unprotect(u"password");
// Save Excel file.
workbook.Save(inputFilePath);
std::cout << "Workbook structure unprotected and saved successfully!" << std::endl;
Aspose::Cells::Cleanup();
}
Observera: Ett korrekt lösenord krävs.