Comments (4)
能不能看看 calcChain里存储的数据? 因为这里和自动计算相关
from luckyexcel.
from luckyexcel.
我写了一个组装calcChain的初版代码,基本能满足导入后calcChain为空数组的问题。
1.组件问题:但是公式多了页面渲染确实会存在性能问题,
2.如果导入excel中存在隐藏列,下方代码 列对应关系也会有问题。
我的代码如下
`
function getCalcChain(sheetIndex,sheetJson){
/*
已知条件
1.celldata的结构如下:
{
"r": 9,
"c": 72,
"v": {
"ct": {
"fa": "#,##0.00"
},
"bg": "#99CCFF",
"fs": 10,
"ff": "宋体",
"ht": 2,
"vt": 0,
"tb": 1,
"v": 0,
"f": "=I10-Y10+AO10+BE10",
"m": "0.00"
}
计算链条calcChain 的结构如下
{
"r": 8, //行数
"c": 5, //列数
"index": luckysheet.getluckysheetfile()[0]["index"], //工作表id
"func": [true, 23.75, "=C9+D9+E9"], //公式信息,包含公式计算结果和公式字符串
"color": "w", //"w":采用深度优先算法 "b":普通计算
"parent": null,
"chidren": {},
"times": 0
}
*/
//var selfCellArray = luckysheet.getluckysheetfile()[sheetIndex]["celldata"];
debugger;
var selfCellArray = sheetJson["celldata"];
var filterCells = [];
for(var i = 0 ;i < selfCellArray.length ; i++){
var itemCell = selfCellArray[i];
if(i == 450){
debugger;
console.log(itemCell);
}
if(isNullObject(itemCell)
|| isNullObject(itemCell["v"])
|| isNullObject(itemCell["v"]["v"] )
|| !isNumberObject(itemCell["v"]["v"])
|| isNullObject(itemCell["v"]["f"])){ //将非数值并且不存在公式的单元格过滤掉
continue;
}
itemCell["self_coordinate"] = getColId(itemCell["c"])+""+itemCell["r"];
itemCell["self_func"] = itemCell["v"]["f"];
filterCells.push(itemCell);
}
var sortCells = bubbleSort(filterCells); //排序后的单元格
var calcChain = [];
for(var i = 0 ;i < sortCells.length ; i++){
var itemCell = sortCells[i];
calcChain.push({
"r": itemCell["r"], //行数
"c": itemCell["c"], //列数
"index": sheetIndex, //工作表id
"func": [true, itemCell["v"]["v"], itemCell["self_func"]], //公式信息,包含公式计算结果和公式字符串
"color": "w", //"w":采用深度优先算法 "b":普通计算
"parent": null,
"chidren": {},
"times": 0
});
}
return calcChain;
}
//冒泡排序
function bubbleSort(arr) {
var len = arr.length;
for(var i = 0; i < len - 1; i++) {
for(var j = 0; j < len - 1 - i; j++) {
if(arr[j]["self_func"].indexOf(arr[j+1]["self_coordinate"]) != -1 ) { //相邻元素两两对比,如果 元素2的公式中存在元素1的坐标则交换位置
var temp = arr[j+1]; // 元素交换
arr[j+1] = arr[j];
arr[j] = temp;
}
}
}
return arr;
}
function getColId( colIndex){ //大小写问题//例如列下标是45,返回AS
if(colIndex == undefined || colIndex == 'undefined' || colIndex == null || colIndex =='null'){
return "";
}
if(colIndex < 26 ){
return String.fromCharCode( "A".charCodeAt() + colIndex );
}
if(colIndex < 26 * 26){
return String.fromCharCode( "A".charCodeAt() + (parseInt(colIndex / 26)-1) ) +""+String.fromCharCode( "A".charCodeAt() + parseInt(colIndex % 26) ); //获取字符的ASCII码 ,大写字母A的ASCII码值是65
}
return "";
}
function getColNumber(col){ //例如列是AS,返回下标45
if(col == undefined || col == 'undefined' || col == null || col =='null'){
return -1;
}
col = col.toUpperCase().trim(); //转换成大写
var colArray = col.split("");
if(indexArray == 1){
return colArray[i].charCodeAt() - "A".charCodeAt() ;
}
if(indexArray == 2){
return (colArray[0].charCodeAt() - "A".charCodeAt()) * 26 +(colArray[1].charCodeAt() - "A".charCodeAt());
}
return -1;
}
function isNumberObject(value) {
return !isNullObject(value) && !isNaN(value);
}
function isNullObject(obj) {
return ( typeof(obj) == "undefined" || obj == null ) ;
}
`
from luckyexcel.
可以把你的excel发出来看看? 现在公式的性能正在逐步优化中。
from luckyexcel.
Related Issues (20)
- 通过luckyexcel导入的xlsx文件,无法使用luckysheet正常显示 HOT 3
- 导入之后下拉列表丢失,查询也没有见到dataVerification字段
- transformExcelToLucky 是否可以只导出前200行数据,节省时间
- 能配置这样的表格模版吗?
- 两年过去了,导出功能还做吗 HOT 1
- excel template is big
- 倒入xlsx文件,打印exportJson,发现 单元格中 以单引号开头的 数据,会丢失一个单引号 HOT 1
- core.mjs:7739 ERROR Error: Ajax error for SafeValue must use HOT 1
- Property 'luckysheet' does not exist on type 'Window & typeof globalThis'. HOT 1
- excel导入不支持形状&组合
- 导出的表格行高不一致 HOT 1
- 使用luckyexcel读取1万行的excel巨慢无比,要1分钟,有用java读取excel转成json返回给luckysheet展示的案例吗
- 导入excel,excel本身存在内容,但是却无法解析出内容。 HOT 1
- excel导入不支持冻结行和列 HOT 1
- Stuck in transformExcelToLucky() when processing Excel files containing images from Node server
- Is this the right way to do Data Validation (Verification)
- 导出功能有了吗?为啥addSheet is not a function
- 支持导出图表吗
- getScreenshot方法不能截取带有图片的excel
- 导入excel时,自动换行格式丢失,需要改wrapText的判断值
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luckyexcel.