mirror of
https://github.com/dream-num/univer.git
synced 2026-08-28 23:01:30 +08:00
fix(paste): fix the style error when copying cells with conditional formatting, data validation, number formatting, etc. (#6326)
This commit is contained in:
@@ -261,7 +261,10 @@ export class SheetClipboardController extends RxDisposable {
|
||||
}
|
||||
|
||||
const mergedCellByRowCol = currentSheet!.getMergedCell(row, col);
|
||||
|
||||
/**
|
||||
* This is for generating the copied HTML, which requires all the styles applied to the cell, including conditional formatting, data validation, number format, etc.
|
||||
* So here we use `getComposedCellStyle` to get the final style of the cell.
|
||||
*/
|
||||
const textStyle = currentSheet!.getComposedCellStyle(row, col);
|
||||
|
||||
let style = '';
|
||||
|
||||
@@ -665,7 +665,12 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard
|
||||
const cellMatrix = new ObjectMatrix<ICellDataWithSpanInfo>();
|
||||
cachedMatrix.forValue((row, col, value) => {
|
||||
const { row: actualRow, col: actualColumn } = mapFunc(row, col);
|
||||
const style = worksheet?.getComposedCellStyle(actualRow, actualColumn);
|
||||
/**
|
||||
* This only needs to include a combination of default styles, row and column styles, and cell styles.
|
||||
* Conditional formatting, data validation, and number format are not included here because they will be applied automatically after pasting.
|
||||
* So here we use `getComposedCellStyleByCellData` to get the final style of the cell raw data.
|
||||
*/
|
||||
const style = worksheet?.getComposedCellStyleByCellData(actualRow, actualColumn, value);
|
||||
const newValue = cloneCellDataWithSpanInfo(value)!;
|
||||
newValue.s = style;
|
||||
cellMatrix.setValue(row, col, newValue);
|
||||
|
||||
Reference in New Issue
Block a user