Skip to content

Conversation

BrianHung
Copy link
Contributor

feat: return sheet name and index from newSheet

The returned sheet_index can be directly used with other API methods like renameSheet() and setUserInput().

BrianHung added a commit to BrianHung/IronCalc that referenced this pull request Jun 13, 2025
Copy link
Member

@nhatcher nhatcher left a comment

Choose a reason for hiding this comment

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

This is actually a nice change. Can you:

  • Rebase main
  • Add tests in the Rust base module also

#[napi(js_name = "newSheet")]
pub fn new_sheet(&mut self) -> Result<()> {
self.model.new_sheet().map_err(to_js_error)
self.model.new_sheet().map(|_| ()).map_err(to_js_error)
Copy link
Member

Choose a reason for hiding this comment

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

We would want to return the name also here to be consistent.


let result = NewSheetResult { name, sheet_index };

serde_wasm_bindgen::to_value(&result).map_err(|e| to_js_error(e.to_string()))
Copy link
Member

Choose a reason for hiding this comment

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

Can you just return (name, index)? Maybe not I haven't tried.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LMK if changes work for you!

@BrianHung
Copy link
Contributor Author

Rebased against main and added a test for core and user_model.

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