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

feat(facade): add set font apis and get cell model data api #1266

Merged
merged 8 commits into from Feb 6, 2024

Conversation

hexf00
Copy link
Member

@hexf00 hexf00 commented Jan 25, 2024

  • I am sure that the code is update-to-date with the dev branch.

close #1009

Add Facade range APIs:

  • getCellData
const activeSheet = univerAPI.getActiveWorkbook().getActiveSheet();


const range = activeSheet.getRange(0, 0);
range.setValue('a');

// 获取单元格数据
const cellData = range .getCellData(); // like { v : "a" }
  • getCellStyleData
const activeSheet = univerAPI.getActiveWorkbook().getActiveSheet();

// 获取单元格样式数据
const range = activeSheet.getRange(0, 0);
range.setFontWeight('bold');

const cellStyleData = activeSheet.getRange(0, 0).getCellStyleData(); // reuslt like { bl: 1 }
  • setFontStyle
  • setFontLine
  • setFontFamily
  • setFontSize
  • setFontColor
const activeSheet = univerAPI.getActiveWorkbook().getActiveSheet();

// 设置单元格样式数据
const range = activeSheet.getRange(0, 0, 2, 2);
range
  .setFontWeight('bold')
  .setFontLine('underline')
  .setFontFamily('Arial')
  .setFontSize(24)
  .setFontColor('red');

//移除单元格样式数据
range
  .setFontWeight(null)
  .setFontLine(null)
  .setFontFamily(null)
  .setFontSize(null)
  .setFontColor(null);

Copy link

codecov bot commented Jan 25, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (15c7ca0) 29.63% compared to head (14c722e) 29.72%.

Files Patch % Lines
packages/facade/src/apis/sheet/f-range.ts 90.27% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1266      +/-   ##
==========================================
+ Coverage   29.63%   29.72%   +0.08%     
==========================================
  Files         843      843              
  Lines       47792    47859      +67     
  Branches     9795     9811      +16     
==========================================
+ Hits        14162    14224      +62     
- Misses      33630    33635       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Jan 25, 2024

View Deployment

📑 Examples 📚 Storybook
🔗 Preview link 🔗 Preview link

@hexf00 hexf00 force-pushed the feat/facade-set-font-style branch 2 times, most recently from 09a5897 to f9cd97d Compare January 26, 2024 03:41
@hexf00 hexf00 requested a review from wzhudev January 26, 2024 03:46
Copy link
Member

@wzhudev wzhudev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! Though minor changes would be appreciated.

style,
};

this._commandService.executeCommand(SetStyleCommand.id, setStyleParams);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetStyleCommand 改成同步的命令吧,然后这里变成 syncExecuteCommand

Copy link
Member Author

@hexf00 hexf00 Feb 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里参照 Apps Scripts 设计,是链式调用,没有返回调用的状态。 保持异步调用会不会更快?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不会,SetStyleCommand 内部实现就是同步的

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

了解了,后续调整下

packages/facade/src/apis/sheet/f-range.ts Outdated Show resolved Hide resolved
packages/facade/src/apis/sheet/f-range.ts Show resolved Hide resolved
packages/facade/src/apis/sheet/__tests__/f-range.spec.ts Outdated Show resolved Hide resolved
packages/facade/src/apis/sheet/__tests__/f-range.spec.ts Outdated Show resolved Hide resolved
@wzhudev wzhudev merged commit d0a8709 into dream-num:dev Feb 6, 2024
7 checks passed
Dushusir pushed a commit that referenced this pull request Feb 7, 2024
* feat(facade): export FontWeight

* feat(facade): add getCellData、getCellStyleData、setFontStyle、setFontLine

* feat(facade): add setFontFamily

* feat(facade): add setFontSize

* feat(facade): add setFontColor

* fix(sheet): setRangeValues judging null

* test(facade): test composite set font style

* refactor(facade): refactor set font style
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.

[Feature] add more API to Facade
2 participants