Skip to content

feat: Support shapes and text boxes #2601

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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

kigh-ota
Copy link
Contributor

@kigh-ota kigh-ota commented Nov 24, 2023

Summary

I created this PR based on DantSu's #2077, which I think is a great work and highly appreciate.

This PR add basic support of reading/writing shapes and textboxes.
This can broaden the use cases of the library, for example, we can load, modify and save existing Excel files including shapes and textboxes without losing them (related issues: #1147, #2086).

To help making the PR closer to merge, compared to the DantSu's PR, I did:

  • add some unit/integration tests
  • add type definitions (index.d.ts)
  • change the structure of some models
  • resolve conflicts with the current HEAD
  • add some functionalities like inner texts, line dashes and alignments

Note that some common functionalities, e.g. scRGB colors, font types and strikethrough styles, are still lacked in this PR.
I'm also willing to add a part to README document.

Test plan

ws.addShape({
  type: 'roundRect',
  rotation: 15,
  fill: { type: 'solid', color: { rgb: '4499FF' } },
  outline: { weight: 2, color: { rgb: '446699' }, dash: 'sysDash' },
  textBody: {
    vertAlign: 'ctr',
    paragraphs: [
      { alignment: 'l', runs: ["Lorem ipsum dolor sit amet, consectetur adipiscing elit."] },
      { alignment: 'r', runs: [
        { text: "Nulla eget odio sed libero ultrices vehicula.", font: { bold: true, color: { rgb: 'FF0000' } } },
      ] },
    ],
  },
}, 'B2:H8', {
  hyperlink: 'https://www.example.com',
  tooltip: 'Example Link',
});

285531607-506e7f43-9694-44b9-863d-0627e3c3ea63

Related to source code (for typings update)

@kigh-ota kigh-ota changed the title Support shapes and text boxes feat: Support shapes and text boxes Nov 24, 2023
@ijash
Copy link

ijash commented May 13, 2024

is there any way that i can use your fork as dependency? waititng the mantainer is taking too long.

@kigh-ota
Copy link
Contributor Author

kigh-ota commented May 13, 2024

@ijash
One possible way is to use patch-package to locally apply the patch, though you may have to recreate and maintain the patch when you upgrade exceljs version on your package.json.

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.

2 participants