Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add protection to styles #95

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

supermonkeybrainz
Copy link

This adds the protection option to styles for cells. This allows users to lock specific cells. There are other protection options, but this is a good start.

@supermonkeybrainz
Copy link
Author

supermonkeybrainz commented Mar 23, 2024

Allows you to do stuff like this:

  const styles = {
    // Create a reusable style
    unlocked: workbook.createStyle({
      protection: { hidden: false, locked: false },
    }),
  };
  
  worksheet
        .cell(1, 1)
        .string(`test`)
        .style(styles.unlocked);

Then you can lock the sheet like this:

    const worksheetOptions = {
      sheetProtection: { objects: true, scenarios: true, sheet: true },
    };
    const worksheet = workbook.addWorksheet('Test', worksheetOptions);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant