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

[Feature] Request: Support Range Copy-Paste through API #4645

Open
2 tasks done
levi-li-yi opened this issue Feb 14, 2025 · 1 comment
Open
2 tasks done

[Feature] Request: Support Range Copy-Paste through API #4645

levi-li-yi opened this issue Feb 14, 2025 · 1 comment

Comments

@levi-li-yi
Copy link

levi-li-yi commented Feb 14, 2025

Initial checklist

  • Is this really a problem?
  • I have searched the Github Issues for similar issues, but did not find anything.

Problem

When using a spreadsheet library, users usually need to copy and paste the contents of the table through mouse operations. In some application scenarios, we hope to complete a certain range of copy and paste operations through APIs, such as:

  • Automatically handle data migration in the background.
  • Implement automated copy and paste functionality in custom shortcut keys or toolbars.
  • When integrating complex business logic, avoid relying on user manual operations.

The current library supports copying and pasting through mouse operations, but lacks an API that directly executes this operation through code. Implementing this feature will enhance the flexibility and automation capabilities of developers.

I suggest adding an API for copying and pasting scopes, for example:

  • Copy: Provides a method for copying the contents of a specified range of cells into memory (similar to a clipboard), supporting Row and Column ranges.

  • Paste: Provides a method for pasting the contents of a cell saved in memory into a target range.

  • Functional requirements:

    1. Support simultaneous copying of content and formats (such as color ,font and merge), and allow for individual selection of whether to copy formats.
    2. When the size of the source range and the target range are inconsistent, support circular pasting by row/column, or throw an error.
    3. You can specify whether to cover existing data within the target range through parameters.

example pseudocode:
// 假设 sheet是电子表格实例 const range = { startRow: 1, startCol: 1, numRows: 3, numColumns: 3 }; sheet.copyRange(range); // 将范围 (1,1) 到 (3,3) 的所有内容复制
// 粘贴到目标范围 (5,5) 开始的区域 const targetRange = { startRow: 5, startCol: 5 }; sheet.pasteRange(targetRange, { includeFormat: true }); // includeFormat 表示是否同时粘贴格式

@univer-bot
Copy link

univer-bot bot commented Feb 14, 2025

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: [Feature] Request: Support Range Copy-Paste through API

Title: [Feature] Request: Support Range Copy-Paste through API


Initial checklist

  • Is this really a problem?
  • I have searched the Github Issues for similar issues, but did not find anything.

Problem

When using a spreadsheet library, users usually need to copy and paste the contents of the table through mouse operations. In some application scenarios, we hope to complete a certain range of copy and paste operations through APIs, such as:

  • Automatically handle data migration in the background.
  • Implement automated copy and paste functionality in custom shortcut keys or toolbars.
  • When integrating complex business logic, avoid relying on user manual operations.

The current library supports copying and pasting through mouse operations, but lacks an API that directly executes this operation through code. Implementing this feature will enhance the flexibility and automation capabilities of developers.

I suggest adding an API for copying and pasting scopes, for example:

  • Copy: Provides a method for copying the contents of a specified range of cells into memory (similar to a clipboard), supporting Row and Column ranges.

  • Paste: Provides a method for pasting the contents of a cell saved in memory into a target range.

  • Functional requirements:

    1. Support simultaneous copying of content and formats (such as color ,font and merge), and allow for individual selection of whether to copy formats.
    2. When the size of the source range and the target range are inconsistent, support circular pasting by row/column, or throw an error.
    3. You can specify whether to cover existing data within the target range through parameters.

example pseudocode:
// 假设 sheet是电子表格实例 const range = { startRow: 1, startCol: 1, numRows: 3, numColumns: 3 }; sheet.copyRange(range); // 将范围 (1,1) 到 (3,3) 的所有内容复制
// 粘贴到目标范围 (5,5) 开始的区域 const targetRange = { startRow: 5, startCol: 5 }; sheet.pasteRange(targetRange, { includeFormat: true }); // includeFormat 表示是否同时粘贴格式

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

No branches or pull requests

4 participants