wpxp123456 5 years ago
parent
commit
ae529ef097
  1. 6
      README-zh.md
  2. 6
      README.md
  3. 95
      docs/zh/guide/api.md
  4. 8
      src/controllers/constant.js
  5. 13
      src/controllers/freezen.js
  6. 41
      src/controllers/sheetmanage.js
  7. 7
      src/core.js
  8. 3301
      src/css/luckysheet-core.css
  9. 3
      src/function/func.js
  10. 6
      src/function/functionImplementation.js
  11. 1168
      src/global/api.js
  12. 4
      src/global/border.js
  13. 135
      src/global/draw.js
  14. 92
      src/global/extend.js
  15. 24
      src/global/formula.js
  16. 1
      src/global/refresh.js
  17. 6
      src/global/setdata.js
  18. 42
      src/index.html
  19. 1
      src/store/index.js

6
README-zh.md

@ -16,6 +16,10 @@
![演示](/docs/.vuepress/public/img/LuckysheetDemo.gif)
## 插件
- excel导入导出库: [Luckyexcel](https://github.com/mengshukeji/Luckyexcel)
- 图表插件: [chartMix](https://github.com/mengshukeji/chartMix)
## 特性
### 🛠️格式设置
@ -85,6 +89,7 @@
+ **矩阵计算** (通过右键菜单进行支持:对选区内的数据进行转置、旋转、数值计算)
+ **截图** (把选区的内容进行截图展示)
+ **复制到其他格式** (右键菜单的"复制为", 支持复制为json、array、对角线数据、去重等)
+ **EXCEL,CSV,TXT 导入及导出** (专为Luckysheet打造的导入导出插件,支持密码、水印、公式等的本地导入导出)
### ⏱️未来开发计划
+ **插入图表和svg形状** (支持JPG,PNG,SVG,Pen tool的插入、修改和删除,并且随表格的变动而产生变化)
@ -93,7 +98,6 @@
+ **单元格内多样式** (Alt+Enter单元格内换行、上标、下标、单元格内科定义每个文字的不同样式)
+ **树形菜单** (类似excel中的分级显示(分组))
+ **表格新功能** (类似excel中表格的筛选器和切片器)
+ **EXCEL,CSV,TXT 导入及导出** (专为Luckysheet打造的导入导出插件,支持密码、水印、公式等的本地导入导出)
+ **文档** (完善文档和API)
+ **敬请期待...** (可以提出好的建议给我们)

6
README.md

@ -22,6 +22,10 @@ English| [简体中文](./README-zh.md)
![Demo](/docs/.vuepress/public/img/LuckysheetDemo.gif)
## Plugins
- Excel import and export library: [Luckyexcel](https://github.com/mengshukeji/Luckyexcel)
- Chart plugin: [chartMix](https://github.com/mengshukeji/chartMix)
## Features
### 🛠️Formatting
@ -91,6 +95,7 @@ English| [简体中文](./README-zh.md)
+ **Matrix operation** (Operate selection through the right-click menu: transpose, rotate, numerical calculation)
+ **Screenshot** (Take a screenshot with selection)
+ **Copy to** (In the right-click menu, copy selection to json, array etc.)
+ **EXCEL,CSV,TXT import/export** (Specially adapted to Luckysheet)
### ⏱️Coming soon
+ **Insert picture and Shapes** (JPG,PNG,SVG,Pen tool and so on)
@ -99,7 +104,6 @@ English| [简体中文](./README-zh.md)
+ **Cell segmentation style** (Alt+Enter line break, sub,super, in-cell style)
+ **Tree menu** (Just like the outline (group) function of excel)
+ **Table new Features** (filter, slicer)
+ **EXCEL,CSV,TXT import/export** (Specially adapted to Luckysheet)
+ **Documentation** (Improve documentation and API)
+ **More...** (Please advise us)

95
docs/zh/guide/api.md

@ -50,7 +50,9 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
- **说明**
设置某个单元格的值,也可以设置整个单元格对象,用于同时设置多个单元格属性
设置某个单元格的值,也可以设置整个单元格对象,用于同时设置多个单元格属性。
如果需要更新公式,也可以在这里赋值,Luckysheet在内部会主动把这个公式做计算并加入到公式链中,最后重刷界面。
- **示例**:
@ -59,6 +61,54 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
------------
### clearCell(row, column [,setting])
- **参数**
- {Number} [row]: 单元格所在行数;从0开始的整数,0表示第一行
- {Number} [column]: 单元格所在列数;从0开始的整数,0表示第一列
- {PlainObject} [setting]: 可选参数
+ {Number} [order]: 工作表索引;默认值为当前工作表索引
+ {Function} [success]: 操作结束的回调函数
- **说明**
清除指定工作表指定单元格的内容,返回清除掉的数据,不同于删除单元格的功能,不需要设定单元格移动情况
- **示例**:
- 清空单元格`B2`内容
`luckysheet.clearCell(1,1)`
------------
### deleteCell(move, row, column [,setting])
- **参数**
- {String} [move]: 删除后,右侧还是下方的单元格移动
`move`可能的值有:
+ `"left"`: 右侧单元格左移
+ `"up"`: 下方单元格上移
- {Number} [row]: 单元格所在行数;从0开始的整数,0表示第一行
- {Number} [column]: 单元格所在列数;从0开始的整数,0表示第一列
- {PlainObject} [setting]: 可选参数
+ {Number} [order]: 工作表索引;默认值为当前工作表索引
+ {Function} [success]: 操作结束的回调函数
- **说明**
删除指定工作表指定单元格,返回删除掉的数据,同时,指定是右侧单元格左移还是下方单元格上移
- **示例**:
- 删除当前单元格并且在删除后,右侧单元格左移
`luckysheet.deleteCell('left')`
------------
### setCellFormat(row, column, attr, value [,setting])
- **参数**
@ -66,9 +116,9 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
- {Number} [row]: 单元格所在行数;从0开始的整数,0表示第一行
- {Number} [column]: 单元格所在列数;从0开始的整数,0表示第一列
- {String} [attr]: 属性类型,参考 [单元格属性表](/zh/guide/cell.html)的属性值
- {String | Number | Object} [value]: 具体的设置值,一个属性会对应多个值,参考 [单元格属性表](/zh/guide/cell.html)的值示例,特殊情况:如果属性类型`attr`是单元格格式`ct`,则设置值`value`应提供`ct.fa`,比如设置A1单元格的格式为百分比格式:
- {String | Number | Object} [value]: 具体的设置值,一个属性会对应多个值,参考 [单元格属性表](/zh/guide/cell.html)的值示例,如果属性类型`attr`是单元格格式`ct`,则设置值`value`应提供ct对象,如:`{fa:"General", t:"g"}`,比如设置A1单元格的格式为百分比格式:
`luckysheet.setCellFormat(0, 0, "ct", "0.00%")`
`luckysheet.setCellFormat(0, 0, "ct", {fa:"0.00%", t:"n"})`
- {PlainObject} [setting]: 可选参数
+ {Number} [order]: 工作表索引;默认值为当前工作表索引
@ -143,7 +193,7 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
- **示例**:
- 当前工作表查找`"value"`字符串并替换为`"out"`
`luckysheet.replaces("value", "out)`
`luckysheet.replace("value", "out")`
------------
@ -910,6 +960,8 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
将一个单元格数组数据赋值到指定的区域,数据格式同`getRangeValue`方法取到的数据。
注意一点,通常`getRangeValue`方法只是取得选区数据,但是不包含边框和合并单元格信息,当执行`setRangeValue`的时候,会动态判断上一步是否执行过`getRangeValue`,如果执行过,会将边框和合并单元格信息一并从Luckysheet配置中取得。
- **示例**:
+ 赋值到当前选区
@ -1810,6 +1862,41 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
`luckysheet.setSheetMove("left")`
- 第二个工作表移动到第四个工作表的索引位置
`luckysheet.setSheetMove(3,{order:1})`
------------
### setSheetOrder(orderList [,setting])
- **参数**
- {Array} [orderList]: 工作表顺序,设置工作表的index和order来指定位置,如:
```json
[
{index:'sheet_01',order: 2},
{index:'sheet_02',order: 1},
{index:'sheet_03',order: 0},
]
```
数组中顺序并不重要,关键是指定sheet index和order的对应关系。
- {PlainObject} [setting]: 可选参数
+ {Function} [success]: 操作结束的回调函数
- **说明**
重新排序所有工作表的位置,指定工作表顺序的数组。
- **示例**:
- 重排工作表,此工作簿含有3个工作表
```js
luckysheet.setSheetOrder([
{index:'sheet_01',order: 2},
{index:'sheet_02',order: 1},
{index:'sheet_03',order: 0},
])
```
------------

8
src/controllers/constant.js

@ -9,12 +9,12 @@ const gridHTML = function(){
return `<div class="luckysheet">
<canvas id="luckysheetTableContentF" style="display:none;" class="luckysheetTableContent"></canvas>
<div class="luckysheet-work-area luckysheet-noselected-text">
<div class="luckysheet-share-logo" title="\${logotitle}"></div>
<div id ="luckysheet_info_detail" class="luckysheet_info_detail">
<div data-tips="${locale_info.return}" id="luckysheet_info_detail_title" class="luckysheet_info_detail_title">
<i style="margin-left: -2px;" class="fa fa-chevron-left" aria-hidden="true"></i>
<div data-tips="${locale_info.return}" id="luckysheet_info_detail_title" class="luckysheet_info_detail_back">
<i style="color:#444D5A;" class="fa fa-angle-left fa-2x" aria-hidden="true"></i>
</div>
<div>
<div class="luckysheet-share-logo" title="\${logotitle}"></div>
<div class="sheet-name">
<input data-tips="${locale_info.tips}" id="luckysheet_info_detail_input" class="luckysheet_info_detail_input luckysheet-mousedown-cancel" value="${locale_info.noName}" tabindex="0" dir="ltr" aria-label="${locale_info.rename}" style="visibility: visible; width: 149px;" data-tooltip="${locale_info.rename}">
</div>
<div id="luckysheet_info_detail_update" class="luckysheet_info_detail_update"> ${locale_info.detailUpdate} </div>

13
src/controllers/freezen.js

@ -1512,8 +1512,13 @@ const luckysheetFreezen = {
/**
*
* @param {string} operate "freezenRow"/ "freezenColumn"......
* @param {Number | String} order 工作表索引默认值为当前工作表索引
* @param {Object} focus 冻结选区时的focus单元格行列值构成的对象格式为{ row_focus:0, column_focus:0 }
*/
saveFrozen: function(operate) {
saveFrozen: function(operate, order, focus = {}) {
if (order == null) {
order = getSheetIndex(Store.currentSheetIndex)
}
// New configuration attribute of sheet: frozen, which stores more semantic configuration for initialization and transmission to the backend. freezenhorizontaldata is still used as local data
@ -1523,8 +1528,8 @@ const luckysheetFreezen = {
const column_focus = select_save["column_focus"] == null ? select_save["column"][0] : select_save["column_focus"];
const range = {
row_focus: row_focus,
column_focus: column_focus
row_focus: focus.row_focus || row_focus,
column_focus: focus.column_focus || column_focus
}
const frozen = {
@ -1555,7 +1560,7 @@ const luckysheetFreezen = {
}
// store frozen
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["frozen"] = frozen[operate];
Store.luckysheetfile[order]["frozen"] = frozen[operate];
},
frozenTofreezen: function() {

41
src/controllers/sheetmanage.js

@ -443,7 +443,7 @@ const sheetmanage = {
return true;
}
},
createSheetbydata: function(data, isrenew) {
createSheetbydata: function(data, isrenew, isBefore=true) {
let _this = this;
let colorset = '';
@ -453,13 +453,15 @@ const sheetmanage = {
$("#luckysheet-sheet-container-c").append(replaceHtml(sheetHTML, { "index": data.index, "active": "", "name": data.name, "order": data.order, "style": "", "colorset": colorset }));
let previndex = data.order;
if(previndex >= Store.luckysheetfile.length){
previndex = Store.luckysheetfile.length - 1;
$("#luckysheet-sheets-item" + data.index).insertAfter($("#luckysheet-sheets-item" + Store.luckysheetfile[previndex].index));
}
else{
$("#luckysheet-sheets-item" + data.index).insertBefore($("#luckysheet-sheets-item" + Store.luckysheetfile[previndex].index));
if(isBefore){
let previndex = data.order;
if(previndex >= Store.luckysheetfile.length){
previndex = Store.luckysheetfile.length - 1;
$("#luckysheet-sheets-item" + data.index).insertAfter($("#luckysheet-sheets-item" + Store.luckysheetfile[previndex].index));
}
else{
$("#luckysheet-sheets-item" + data.index).insertBefore($("#luckysheet-sheets-item" + Store.luckysheetfile[previndex].index));
}
}
Store.luckysheetfile.push(data);
@ -1017,6 +1019,29 @@ const sheetmanage = {
file["data"] = data;
file["load"] = "1";
let sheetindexset = _this.checkLoadSheetIndex(file);
let sheetindex = [];
for(let i = 0; i < sheetindexset.length; i++){
let item = sheetindexset[i];
if(item == file["index"]){
continue;
}
sheetindex.push(item);
}
for(let i = 0;i<sheetindex.length;i++){
let item = sheetindex[i];
let otherfile = Store.luckysheetfile[_this.getSheetIndex(item)];
if(otherfile["load"] == null || otherfile["load"] == "0"){
otherfile["data"] = _this.buildGridData(otherfile);
otherfile["load"] = "1";
}
}
_this.mergeCalculation(index);
_this.setSheetParam();
_this.showSheet();

7
src/core.js

@ -32,8 +32,13 @@ import { selectHightlightShow } from './controllers/select';
import {zoomInitial} from './controllers/zoom';
import method from './global/method';
import * as api from './global/api';
let luckysheet = {};
// mount api
luckysheet.api = api;
//创建luckysheet表格
luckysheet.create = function (setting) {
let extendsetting = common_extend(defaultSetting, setting);
@ -180,6 +185,8 @@ luckysheet.setcellvalue = setcellvalue;
// Get selection range value
luckysheet.getdatabyselection = getdatabyselection;
luckysheet.sheetmanage = sheetmanage;
// Data of the current table
luckysheet.flowdata = function () {
return Store.flowdata;

3301
src/css/luckysheet-core.css

File diff suppressed because it is too large

3
src/function/func.js

@ -93,6 +93,9 @@ function luckysheet_compareWith() {
else if(sp == "-" && fp == null){
fp = 0;
}
else if(sp == "/" && (tp == 0 || tp == null)){
return error.d;
}
//计算result
function booleanOperation(a, operator, b){

6
src/function/functionImplementation.js

@ -7,7 +7,7 @@ import formula from '../global/formula';
import func_methods from '../global/func_methods';
import editor from '../global/editor';
import { isdatetime, diff, isdatatype } from '../global/datecontroll';
import { isRealNum, isRealNull, valueIsError } from '../global/validate';
import { isRealNum, isRealNull, valueIsError,error } from '../global/validate';
import { jfrefreshgrid } from '../global/refresh';
import { genarate, update } from '../global/format';
import { orderbydata } from '../global/sort';
@ -19496,7 +19496,7 @@ const functionImplementation = {
//结果为 TRUE
var value_if_true = func_methods.getFirstValue(arguments[1], "text");
if(valueIsError(value_if_true)){
if(valueIsError(value_if_true) && value_if_false!=error.d){
return value_if_true;
}
@ -19504,7 +19504,7 @@ const functionImplementation = {
var value_if_false = "";
if(arguments.length == 3){
value_if_false = func_methods.getFirstValue(arguments[2], "text");
if(valueIsError(value_if_false)){
if(valueIsError(value_if_false) && value_if_false!=error.d){
return value_if_false;
}
}

1168
src/global/api.js

File diff suppressed because it is too large

4
src/global/border.js

@ -731,7 +731,7 @@ function getBorderInfoCompute(sheetIndex) {
if(data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null){
let cell = data[bd_r][bd_c];
let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c];
let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c] || {};
if(mc.c == bd_c){
if(borderInfoCompute[bd_r + "_" + bd_c] == null){
@ -823,7 +823,7 @@ function getBorderInfoCompute(sheetIndex) {
if(data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null){
let cell = data[bd_r][bd_c];
let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c];
let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c] || {};
if(value.l != null && bd_c == mc.c){ //左边框
borderInfoCompute[bd_r + "_" + bd_c].l = { "color": value.l.color, "style": value.l.style };

135
src/global/draw.js

@ -7,7 +7,7 @@ import { luckysheetdefaultstyle, luckysheet_CFiconsImg,luckysheetdefaultFont } f
import { luckysheet_searcharray } from '../controllers/sheetSearch';
import { dynamicArrayCompute } from './dynamicArray';
import browser from './browser';
import { isRealNull } from './validate';
import { isRealNull, isRealNum } from './validate';
import { getCellTextSplitArr,getMeasureText } from './getRowlen';
import { getcellvalue } from './getdata';
import { getBorderInfoCompute } from './border';
@ -1259,6 +1259,28 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee
luckysheetTableContent.closePath();
}
//若单元格强制为字符串,则显示绿色小三角
if(cell.qp==1 && isRealNum(cell.v)){
let ps_w = 6*Store.zoomRatio, ps_h = 6*Store.zoomRatio; //红色小三角宽高
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
(start_c + offsetLeft + ps_w-1),
(start_r + offsetTop)
);
luckysheetTableContent.lineTo(
(start_c + offsetLeft-1),
(start_r + offsetTop)
);
luckysheetTableContent.lineTo(
(start_c + offsetLeft-1),
(start_r + offsetTop + ps_h)
);
luckysheetTableContent.fillStyle = "#487f1e";
luckysheetTableContent.fill();
luckysheetTableContent.closePath();
}
//溢出单元格
let cellOverflow_bd_r_render = true; //溢出单元格右边框是否需要绘制
let cellOverflow_colInObj = cellOverflow_colIn(cellOverflowMap, r, c, dataset_col_st, dataset_col_ed);
@ -1546,63 +1568,74 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee
//自动换行
// luckysheetTableContent.textBaseline = 'top'; //textBaseline以top计算
let strArr = [];//文本截断数组
strArr = getCellTextSplitArr(value.toString(), strArr, (cellWidth - space_width * 2), luckysheetTableContent);
let word_space_height = oneLineTextHeight/3;
for(let i = 0; i < strArr.length; i++){
let strV = strArr[i];
if(cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.sharedStrings!=null && cell.ct.sharedStrings.length>0){
let strArr = [],lineMaxHeight=[];
let sharedStrings = cell.ct.sharedStrings;
for(let i=0;i<cell.ct.sharedStrings.length;i++){
let strWidth = getMeasureText(strV, luckysheetTableContent).width;
// luckysheetTableContent.measureText(strV).width;
let strHeight = oneLineTextHeight;
//水平对齐计算
if(horizonAlign == "0"){
horizonAlignPos = (pos_x + cellWidth / 2) - (strWidth / 2);
}
else if(horizonAlign == "2"){
horizonAlignPos = (pos_x + cellWidth - space_width) - strWidth;
}
else{
horizonAlignPos = (pos_x + space_width) ;
}
//垂直对齐计算
let clLine = 0;
if(verticalAlign == "0"){
verticalAlignPos = (pos_y + cellHeight / 2) - (strHeight+word_space_height) * (strArr.length-1)/2;
}
else if(verticalAlign == "1"){
verticalAlignPos = (pos_y + space_height) ;
clLine = strHeight / 2;
}
else{
verticalAlignPos = (pos_y + cellHeight - space_height) - (strHeight+word_space_height) * (strArr.length-1);
clLine = -strHeight / 2;
}
}
else{
let strArr = [];
strArr = getCellTextSplitArr(value.toString(), strArr, (cellWidth - space_width * 2), luckysheetTableContent);
let word_space_height = oneLineTextHeight/3;
for(let i = 0; i < strArr.length; i++){
let strV = strArr[i];
let strWidth = getMeasureText(strV, luckysheetTableContent).width;
// luckysheetTableContent.measureText(strV).width;
let strHeight = oneLineTextHeight;
//水平对齐计算
if(horizonAlign == "0"){
horizonAlignPos = (pos_x + cellWidth / 2) - (strWidth / 2);
}
else if(horizonAlign == "2"){
horizonAlignPos = (pos_x + cellWidth - space_width) - strWidth;
}
else{
horizonAlignPos = (pos_x + space_width) ;
}
//垂直对齐计算
let clLine = 0;
if(verticalAlign == "0"){
verticalAlignPos = (pos_y + cellHeight / 2) - (strHeight+word_space_height) * (strArr.length-1)/2;
}
else if(verticalAlign == "1"){
verticalAlignPos = (pos_y + space_height) ;
clLine = strHeight / 2;
}
else{
verticalAlignPos = (pos_y + cellHeight - space_height) - (strHeight+word_space_height) * (strArr.length-1);
clLine = -strHeight / 2;
}
verticalAlignPos = (verticalAlignPos + i * (strHeight+word_space_height));
verticalAlignPos = verticalAlignPos/Store.zoomRatio;
horizonAlignPos = horizonAlignPos/Store.zoomRatio;
verticalAlignPos = (verticalAlignPos + i * (strHeight+word_space_height));
verticalAlignPos = verticalAlignPos/Store.zoomRatio;
horizonAlignPos = horizonAlignPos/Store.zoomRatio;
luckysheetTableContent.fillText(strV, horizonAlignPos, verticalAlignPos);
luckysheetTableContent.fillText(strV, horizonAlignPos, verticalAlignPos);
if(cl == "1" && !isRealNull(strV)){
luckysheetTableContent.beginPath();
luckysheetTableContent.strokeStyle = "#000";
clLine = clLine/Store.zoomRatio;
luckysheetTableContent.moveTo(
horizonAlignPos,
verticalAlignPos +clLine
);
luckysheetTableContent.lineTo(
horizonAlignPos + strWidth/Store.zoomRatio,
verticalAlignPos + clLine
);
luckysheetTableContent.stroke();
luckysheetTableContent.closePath();
if(cl == "1" && !isRealNull(strV)){
luckysheetTableContent.beginPath();
luckysheetTableContent.strokeStyle = "#000";
clLine = clLine/Store.zoomRatio;
luckysheetTableContent.moveTo(
horizonAlignPos,
verticalAlignPos +clLine
);
luckysheetTableContent.lineTo(
horizonAlignPos + strWidth/Store.zoomRatio,
verticalAlignPos + clLine
);
luckysheetTableContent.stroke();
luckysheetTableContent.closePath();
}
}
}
}
else if(cell.tr != null && cell.tr != '0'){
//旋转

92
src/global/extend.js

@ -1,7 +1,7 @@
import editor from './editor';
import formula from './formula';
import { jfrefreshgrid_adRC, jfrefreshgrid_deleteCell, jfrefreshgrid_rhcw } from './refresh';
import { datagridgrowth } from './getdata';
import { datagridgrowth, getcellFormula } from './getdata';
import { setcellvalue } from './setdata';
import conditionformat from '../controllers/conditionformat';
import luckysheetFreezen from '../controllers/freezen';
@ -11,12 +11,13 @@ import { getSheetIndex } from '../methods/get';
import Store from '../store';
//增加行列
function luckysheetextendtable(type, index, value, direction) {
let d = editor.deepCopyFlowData(Store.flowdata);
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
function luckysheetextendtable(type, index, value, direction, order) {
let curOrder = order || getSheetIndex(Store.currentSheetIndex);
let file = Store.luckysheetfile[curOrder];
let d = file.data;
value = Math.floor(value);
let cfg = $.extend(true, {}, Store.config);
let cfg = $.extend(true, {}, file.config);
//合并单元格配置变动
if(cfg["merge"] == null){
@ -100,7 +101,7 @@ function luckysheetextendtable(type, index, value, direction) {
if(type == "row"){
let functionStr = "=" + formula.functionStrChange(calc_funcStr, "add", "row", direction, index, value);
if(d[calc_r][calc_c].f == calc_funcStr){
if(d[calc_r][calc_c] && d[calc_r][calc_c].f == calc_funcStr){
d[calc_r][calc_c].f = functionStr;
}
@ -122,7 +123,7 @@ function luckysheetextendtable(type, index, value, direction) {
else if(type == "column"){
let functionStr = "=" + formula.functionStrChange(calc_funcStr, "add", "col", direction, index, value);
if(d[calc_r][calc_c].f == calc_funcStr){
if(d[calc_r][calc_c] && d[calc_r][calc_c].f == calc_funcStr){
d[calc_r][calc_c].f = functionStr;
}
@ -715,17 +716,20 @@ function luckysheetextendtable(type, index, value, direction) {
}
}
jfrefreshgrid_adRC(
d,
cfg,
"addRC",
{ "index": index, "len": value, "direction": direction, "rc": type1, "restore": false },
newCalcChain,
newFilterObj,
newCFarr,
newAFarr,
newFreezen
);
// 修改当前sheet页时刷新
if (curOrder == Store.currentSheetIndex) {
jfrefreshgrid_adRC(
d,
cfg,
"addRC",
{ "index": index, "len": value, "direction": direction, "rc": type1, "restore": false },
newCalcChain,
newFilterObj,
newCFarr,
newAFarr,
newFreezen
);
}
let range = null;
if(type == "row"){
@ -745,8 +749,11 @@ function luckysheetextendtable(type, index, value, direction) {
}
}
Store.luckysheet_select_save = range;
selectHightlightShow();
file.luckysheet_select_save = range;
if (curOrder == Store.currentSheetIndex) {
Store.luckysheet_select_save = range;
selectHightlightShow();
}
if (type == "row"){
let scrollLeft = $("#luckysheet-cell-main").scrollLeft(),
@ -810,12 +817,13 @@ function luckysheetextendData(rowlen, newData) {
}
//删除行列
function luckysheetdeletetable(type, st, ed) {
let d = editor.deepCopyFlowData(Store.flowdata);
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
function luckysheetdeletetable(type, st, ed, order) {
let curOrder = order || getSheetIndex(Store.currentSheetIndex);
let file = Store.luckysheetfile[curOrder];
let d = file.data;
let slen = ed - st + 1;
let cfg = $.extend(true, {}, Store.config);
let cfg = $.extend(true, {}, file.config);
//合并单元格配置变动
if(cfg["merge"] == null){
@ -888,7 +896,7 @@ function luckysheetdeletetable(type, st, ed) {
if(calc_r < st || calc_r > ed){
let functionStr = "=" + formula.functionStrChange(calc_funcStr, "del", "row", null, st, slen);
if(d[calc_r][calc_c].f == calc_funcStr){
if(d[calc_r][calc_c] && d[calc_r][calc_c].f == calc_funcStr){
d[calc_r][calc_c].f = functionStr;
}
@ -905,7 +913,7 @@ function luckysheetdeletetable(type, st, ed) {
if(calc_c < st || calc_c > ed){
let functionStr = "=" + formula.functionStrChange(calc_funcStr, "del", "col", null, st, slen);
if(d[calc_r][calc_c].f == calc_funcStr){
if(d[calc_r][calc_c] && d[calc_r][calc_c].f == calc_funcStr){
d[calc_r][calc_c].f = functionStr;
}
@ -1470,23 +1478,27 @@ function luckysheetdeletetable(type, st, ed) {
}
}
jfrefreshgrid_adRC(
d,
cfg,
"delRC",
{ "index": st, "len": ed - st + 1, "rc": type1 },
newCalcChain,
newFilterObj,
newCFarr,
newAFarr,
newFreezen
);
// 修改当前sheet页时刷新
if (curOrder == Store.currentSheetIndex) {
jfrefreshgrid_adRC(
d,
cfg,
"delRC",
{ "index": st, "len": ed - st + 1, "rc": type1 },
newCalcChain,
newFilterObj,
newCFarr,
newAFarr,
newFreezen
);
}
}
//删除单元格
function luckysheetDeleteCell(type, str, edr, stc, edc) {
function luckysheetDeleteCell(type, str, edr, stc, edc, order) {
let d = editor.deepCopyFlowData(Store.flowdata);
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
let curOrder = order || getSheetIndex(Store.currentSheetIndex);
let file = Store.luckysheetfile[curOrder];
let rlen = edr - str + 1;
let clen = edc - stc + 1;
@ -1551,7 +1563,7 @@ function luckysheetDeleteCell(type, str, edr, stc, edc) {
}
}
if(d[calc_r][calc_c].f == calc_funcStr){
if(d[calc_r][calc_c] && d[calc_r][calc_c].f == calc_funcStr){
d[calc_r][calc_c].f = functionStr;
}

24
src/global/formula.js

@ -309,10 +309,8 @@ const luckysheetformula = {
oldvalue: null,
dontupdate: function() {
let _this = this;
Store.luckysheetCellUpdate.length = 0; //clear array
$("#luckysheet-functionbox-cell, #luckysheet-rich-text-editor").html(_this.oldvalue);
_this.cancelNormalSelected();
if (_this.rangetosheet != Store.currentSheetIndex) {
sheetmanage.changeSheetExec(_this.rangetosheet);
@ -1209,7 +1207,7 @@ const luckysheetformula = {
return;
}
}
else{
else if(curv!=null && curv.qp != 1){
if (getObjType(curv) == "object" && (value == curv.f || value == curv.v || value == curv.m)) {
_this.cancelNormalSelected();
return;
@ -1267,6 +1265,14 @@ const luckysheetformula = {
delete curv.f;
delete curv.spl;
if(curv.qp == 1 && value.substr(0,1)!="'"){//if quotePrefix is 1, cell is force string, cell clear quotePrefix when it is updated
curv.qp = 0;
if(curv.ct!=null){
curv.ct.fa = "General";
curv.ct.t = "n";
}
}
}
value = curv;
@ -3614,7 +3620,10 @@ const luckysheetformula = {
_this.operatorjson = op;
}
if (txt.substr(0, 1) == "=") {
if (txt.substr(0, 2) == "=+") {
txt = txt.substr(2);
}
else if (txt.substr(0, 1) == "=") {
txt = txt.substr(1);
}
@ -4483,8 +4492,11 @@ const luckysheetformula = {
for (let i = 0; i < group.length; i++) {
let item = group[i];
let cell = luckysheetfile[getSheetIndex(item["index"])].data[item.r][item.c];
let file =luckysheetfile[getSheetIndex(item["index"])];
if(file==null){
continue;
}
let cell = file.data[item.r][item.c];
let calc_funcStr = getcellFormula(item.r, item.c, item.index, _this.execFunctionGroupData);
if(cell != null && cell.f != null && cell.f == calc_funcStr){
if(!(item instanceof Object)){

1
src/global/refresh.js

@ -2,6 +2,7 @@ import rhchInit from './rhchInit';
import formula from './formula';
import editor from './editor';
import { setcellvalue } from './setdata';
import { getcellFormula } from './getdata';
import { computeRowlenArr } from './getRowlen';
import {
luckysheetDrawMain,

6
src/global/setdata.js

@ -58,6 +58,12 @@ function setcellvalue(r, c, d, v) {
cell.m = vupdate.toString().substr(1);
cell.ct = { "fa": "@", "t": "s" };
cell.v = vupdate.toString().substr(1);
cell.qp = 1;
}
else if(cell.qp == 1){
cell.m = vupdate.toString();
cell.ct = { "fa": "@", "t": "s" };
cell.v = vupdate.toString();
}
else if(vupdate.toString().toUpperCase() === "TRUE"){
cell.m = "TRUE";

42
src/index.html

@ -37,7 +37,47 @@
allowEdit:true,
forceCalculation:false,
plugins: ['chart'],
data: [sheetCell,sheetFormula,sheetConditionFormat,sheetTable,sheetSparkline,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart]
data: [{"name":"Sheet1","config":{"columnlen":{"0":241},"rowlen":{"0":81}},"index":"1","status":"1","order":"0","luckysheet_select_save":[{"row":[0,0],"column":[4,4],"sheetIndex":1}],"zoomRatio":1,"showGridLines":"1","defaultColWidth":72,"defaultRowHeight":18,"celldata":[
{"r":0,"c":0,
"v":{
"ct":{
"fa":"General",
"t":"inlineStr",
"sharedStrings":[
{
"ff":"等线", //font family
"fc":"#fff000",//font color
"fs":12,//font size
"cl":1,//strike
"un":0,//underline
"bl":0,//blod
"it":1,//italic
v:"我在"
},
{
"t":1,//换行符
},
{
"ff":"等线", //font family
"fc":"#ff0000",//font color
"fs":14,//font size
"cl":"1",//strike
"un":"0",//underline
"bl":"1",//blod
"it":"0",//italic
v:"马路边"
},
]
},
"fs":11,
"ff":"等线",
"vt":0,
"tb":2,
"v":"",
"qp":1,
}
}
],"calcChain":[]}]
})
})

1
src/store/index.js

@ -124,6 +124,7 @@ const Store = {
visibledatarow_unique:null,
showGridLines:true,
}
export default Store;
Loading…
Cancel
Save