C++ ile Çalışma Sayfasını Koru ve Kaldır

MS Excel’de Çalışma Sayfasını Koru ve Kaldır

çalışma sayfasını koruma ve kaldırma

  1. Tıklayın İncele > Sayfayı Koru.
  2. Şifre kutusuna bir şifre girin.
  3. izin ver seçeneklerini seçin.
  4. Tamam‘ı seçin, şifreyi teyit etmek için tekrar girin, ardından tekrar Tamam‘ı seçin.

Aspose.Cells for C++ kullanarak Çalışma Sayfasını Koru

Excel dosyalarının çalışma sayfasını korumak için sadece aşağıdaki basit kod satırlarına ihtiyaç vardır.

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // Create a new workbook
    Workbook workbook;

    // Get the first worksheet
    Worksheet sheet = workbook.GetWorksheets().Get(0);

    // Protect contents of the worksheet
    sheet.Protect(ProtectionType::Contents);

    // Protect worksheet with password
    sheet.GetProtection().SetPassword(u"test");

    // Save as Excel file
    workbook.Save(u"Book1.xlsx");

    std::cout << "Workbook created and protected successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}

Aspose.Cells for C++ kullanarak Çalışma Sayfasının korumasını kaldır

Aspose.Cells API ile çalışma sayfasını korumak kolaydır. Eğer çalışma sayfası şifre ile korunuyorsa doğru bir şifre gereklidir.

#include <iostream>
#include "Aspose.Cells.h"

using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // Create a new workbook
    Workbook workbook(u"Book1.xlsx");

    // Get the first worksheet
    Worksheet sheet = workbook.GetWorksheets().Get(0);

    // Unprotect the worksheet with password
    sheet.Unprotect(u"password");

    // Save the workbook
    workbook.Save(u"Book1.xlsx");

    std::cout << "Worksheet unprotected successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}

Gelişmiş Konular