Proteggi e Sblocca la Struttura del Workbook con C++
Contents
[
Hide
]
Per impedire ad altri utenti di visualizzare i fogli di lavoro nascosti, aggiungere, spostare, eliminare o nascondere fogli di lavoro e rinominare fogli di lavoro, è possibile proteggere la struttura del proprio foglio di lavoro di Excel con una password.
Proteggi e Sblocca la Struttura del Workbook in MS Excel
- Fare clic su Revisione > Proteggi Cartella di Lavoro.
- Inserire una password nella casella di Password.
- Selezionare OK, reinserire la password per confermarla e quindi selezionare di nuovo OK.
Proteggi la Struttura del Workbook usando Aspose.Cells for C++
È sufficiente utilizzare le seguenti linee di codice per implementare la protezione della struttura della cartella di lavoro dei file di Excel.
#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();
}
Sblocca la Struttura del Workbook usando Aspose.Cells for C++
Sbloccare la struttura del workbook è semplice con l’API Aspose.Cells.
#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();
}
Nota: è necessaria una password corretta.