Browse Source

新增更新sheet的api,外部excel数据复制粘贴到luckysheet识别金额类型的数据

master
CN\wuwx26 5 years ago
parent
commit
f29a8788e2
  1. 19
      docs/guide/api.md
  2. 13
      docs/zh/guide/api.md
  3. 49
      src/global/api.js
  4. 13
      src/global/format.js

19
docs/guide/api.md

@ -2076,9 +2076,6 @@ Use note:
### getConfig([setting]) ### getConfig([setting])
[todo]
- **Parameter** - **Parameter**
- {PlainObject} [setting]: optional parameters - {PlainObject} [setting]: optional parameters
@ -2092,9 +2089,6 @@ Use note:
### setConfig([setting]) ### setConfig([setting])
[todo]
- **Parameter** - **Parameter**
- {PlainObject} [setting]: optional parameters - {PlainObject} [setting]: optional parameters
@ -2105,6 +2099,19 @@ Use note:
Quickly set the current worksheet config configuration Quickly set the current worksheet config configuration
------------
### updataSheet([setting])
- **参数**
- {PlainObject} [setting]: optional parameters
+ {Array} [data]: Worksheet Configuration
+ {Function} [success]: callback function for the end of the operation
- **说明**
Update the corresponding sheet according to the set sheet configuration
------------ ------------
### setSheetAdd([setting]) ### setSheetAdd([setting])

13
docs/zh/guide/api.md

@ -2062,7 +2062,20 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
快捷设置指定工作表config配置 快捷设置指定工作表config配置
------------ ------------
### updataSheet([setting])
- **参数**
- {PlainObject} [setting]: 可选参数
+ {Array} [data]: 需要更新的工作表配置,参考create这个API的option.data
+ {Function} [success]: 操作结束的回调函数
- **说明**
根据所传的工作表配置,更新相应的工作表
------------
### setSheetAdd([setting]) ### setSheetAdd([setting])
- **参数** - **参数**

49
src/global/api.js

@ -21,7 +21,7 @@ import { isRealNull, valueIsError, isRealNum, isEditMode, hasPartMC } from "./va
import { isdatetime, diff } from "./datecontroll"; import { isdatetime, diff } from "./datecontroll";
import { getBorderInfoCompute } from './border'; import { getBorderInfoCompute } from './border';
import { luckysheetDrawMain } from './draw'; import { luckysheetDrawMain } from './draw';
import pivotTable from '../controllers/pivotTable';
import server from "../controllers/server"; import server from "../controllers/server";
import menuButton from '../controllers/menuButton'; import menuButton from '../controllers/menuButton';
import selection from "../controllers/selection"; import selection from "../controllers/selection";
@ -6615,6 +6615,53 @@ export function refreshFormula (success) {
}) })
} }
/**
* 更新sheet数据
* @param {Array} data 工作簿配置可以包含多个表
* @param {Object} options 可选参数
* @param {Function} options.success 操作结束的回调函数
*
*/
export function updataSheet (options = {}) {
let {data, success} = options
let files = Store.luckysheetfile
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < files.length; j++) {
if (files[j].index === data[i].index) {
files[j] = data[i]
}
}
}
let file = files[sheetmanage.getSheetIndex(Store.currentSheetIndex)],
sheetData = sheetmanage.buildGridData(file);
file.data = sheetData
if (!!file.isPivotTable) {
Store.luckysheetcurrentisPivotTable = true;
if (!isPivotInitial) {
pivotTable.changePivotTable(index);
}
}
else{
Store.luckysheetcurrentisPivotTable = false;
$("#luckysheet-modal-dialog-slider-pivot").hide();
luckysheetsizeauto(false);
}
sheetmanage.mergeCalculation(file["index"]);
sheetmanage.setSheetParam();
setTimeout(function () {
sheetmanage.showSheet();
sheetmanage.restoreCache();
formula.execFunctionGroupForce(luckysheetConfigsetting.forceCalculation);
sheetmanage.restoreSheetAll(Store.currentSheetIndex);
luckysheetrefreshgrid();
if (success && typeof success === 'function') {
success();
}
}, 1);
server.saveParam("shs", null, Store.currentSheetIndex);
}
/** /**
* 刷新状态栏的状态 * 刷新状态栏的状态
* @param {Array} data 操作数据 * @param {Array} data 操作数据

13
src/global/format.js

@ -1764,7 +1764,18 @@ export function genarate(value) {//万 单位格式增加!!!
return null; return null;
} }
if(value.toString().substr(0, 1) === "'"){ if (/^-?[0-9]{1,}[,][0-9]{3}(.[0-9]{1,2})?$/.test(value)) { // 表述金额的字符串,如:12,000.00 或者 -12,000.00
m = value
v = Number(value.split('.')[0].replace(',', ''))
let fa = "#,##0"
if (value.split('.')[1]) {
fa = "#,##0."
for (let i = 0; i < value.split('.')[1].length; i++) {
fa += 0
}
}
ct= {fa, t: "n"}
} else if(value.toString().substr(0, 1) === "'"){
m = value.toString().substr(1); m = value.toString().substr(1);
ct = { "fa": "@", "t": "s" }; ct = { "fa": "@", "t": "s" };
} }

Loading…
Cancel
Save