陈建华的博客
专注web开发
SpreadJs数据格式分析
2014-06-11 09:58:13   阅读3979次

分析SpreadJs的导入导出数据格式,方便利用自己的设计器进行对接。中间需要有适配器进行转换。

下面图片是通过设计器进行设计的,分为两个sheet。

设计器经过保存之后,生成的JSON数据如下。



{
"version":"1.0",//程序版本
"activeSheetIndex":0,
"sheetCount":2,//sheet的数量,此处为2个
"tabStripRatio":0.5,
"tabStripVisible":true,
"tabEditable":true,
"newTabVisible":true,
"referenceStyle":0,
"useWijmoTheme":false,
"canUserEditFormula":true,
"startSheetIndex":0,//刚开始显示的sheet的索引
"allowUndo":true,
"allowUserZoom":true,
"allowUserResize":true,
"allowDragDrop":true,
"allowDragFill":true,
"highlightInvalidData":false,
"autoFitType":0,
"sheets":{//sheet集合数组
    "Sheet1":{//第一个sheet页
        "name":"Sheet1",//sheet的名字
        "defaults":{//默认的参数-这些都是没有设置的单元格的属性,后面的可以单独覆盖
            "rowHeight":20,//行高
            "colWidth":62,//列宽
            "rowHeaderColWidth":40,//显示行索引的那一列的宽度-最左边
            "colHeaderRowHeight":20//显示列索引的那一行的高度-最上边
        },
        "columns":[],
        "rows":[],
        "autoGenerateColumns":true,
        "dataBinding":null,
        "frozenRowCount":0,//冻结区域的行数
        "frozenColCount":0,//冻结区域的列数
        "frozenTrailingRowCount":0,
        "frozenTrailingColCount":0,
        "rowCount":200,//当前sheet的行数
        "columnCount":20,//当前sheet的列数
        "data":{//当前sheet的数据描述-先行再列
            "name":"Sheet1",//当前sheet的名字
            "rowCount":200,当前sheet的行数
            "colCount":20,//当前sheet的列数
            "dataTable":{//要展示的数据集-具体到每一个单元格的属性,不仅仅是数据
                "0":{//第一行
                    "0":{//第一列
                        "value":"data_A1",//单元格的数据
                        "style":{//单元格的样式
                            "_autoFormatter":null//自动格式化
                        }
                    },
                    "1":{
                        "value":"data_B1",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "2":{
                        "value":"data_C1",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "3":{
                        "value":"data_D1",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "4":{
                        "value":1,
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "rs":"e"
                },
                "1":{
                    "0":{
                        "value":"data_A2",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "1":{
                        "value":"data_B2",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "2":{
                        "value":"data_C2",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "3":{
                        "value":"data_D2",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "4":{
                        "value":2,
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "rs":"e"
                },
                "2":{
                    "0":{
                        "value":"data_A3",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "1":{
                        "value":"data_B3",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "2":{
                        "value":"data_C3",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "3":{
                        "value":"data_D3",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "4":{
                        "value":3,
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "rs":"e"
                },
                "3":{
                    "0":{
                        "value":"data_A4",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "1":{
                        "value":"data_B4",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "2":{
                        "value":"data_C4",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "3":{
                        "value":"data_D4",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "4":{
                        "value":4,
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "rs":"e"
                },
                "4":{
                    "0":{
                        "value":"data_A5",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "1":{
                        "value":"data_B5",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "2":{
                        "value":"data_C5",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "3":{
                        "value":"data_D5",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "4":{
                        "value":5,
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "rs":"e"
                },
                "5":{
                    "0":{
                        "value":"data_A6",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "1":{
                        "value":"data_B6",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "2":{
                        "value":"data_C6",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "3":{
                        "value":"data_D6",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "4":{
                        "value":6,
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "rs":"e"
                },
                "6":{
                    "0":{
                        "value":"data_A7",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "1":{
                        "value":"data_B7",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "2":{
                        "value":"data_C7",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "3":{
                        "value":"data_D7",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "4":{
                        "value":7,
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "rs":"e"
                },
                "7":{
                    "5":{
                        "value":28,//单元格的值
                        "formula":"SUM(E1,E2,E3,E4,E5,E6,E7)"//单元格的计算公式
                    },
                    "rs":"e"
                }
            },
            "_rowDataArray":[],
            "_columnDataArray":[],
            "_defaultDataNode":{
                "style":{//除了特殊的已经设置过的其他的单元格的样式
                    "foreColor":"#000000",//字体颜色
                    "hAlign":3,//水平对齐方式
                    "vAlign":0,//垂直对齐方式
                    "imeMode":1
                }
            }
        },
        "sparklineGroupManager":{
            "groups":[]
        },
        "spans":[],//合并单元格的信息
        "selections":{//选中单元格的信息
            "0":{//第一个选中区域的信息-支持多个区域的选择
                "row":8,//行索引-也就是第9行
                "rowCount":1,
                "col":5,//列索引-也就是F列
                "colCount":1
            },
            "selectionPolicy":2,
            "selectionUnit":0,
            "length":1,
            "activeSelectedRangeIndex":0
        },
        "selectionBackColor":"rgba(180,180,200,0.2)",//选中单元格的背景颜色
        "selectionBorderColor":"black",//选中单元格的边框颜色
        "activeRow":8,活动的行索引
        "activeCol":5,//活动的列索引
        "gridline":{//整个表格线的属性
            "color":"#d0d7e5",//颜色值
            "showVerticalGridline":true,//是否显示垂直的表格线
            "showHorizontalGridline":true//是否显示水平的表格线
        },
        "allowCellOverflow":false,//是否允许单元格内容超出显示
        "referenceStyle":0,
        "_zoomFactor":1,//缩放因子
        "theme":{
            "_name":"Office",
            "_themeColor":{
                "_name":"Office",
                "_colorList":[
                    {"a":255,"r":255,"g":255,"b":255},
                    {"a":255,"r":238,"g":236,"b":225},
                    {"a":255,"r":0,"g":0,"b":0},
                    {"a":255,"r":31,"g":73,"b":125},
                    {"a":255,"r":79,"g":129,"b":189},
                    {"a":255,"r":192,"g":80,"b":77},
                    {"a":255,"r":155,"g":187,"b":89},
                    {"a":255,"r":128,"g":100,"b":162},
                    {"a":255,"r":75,"g":172,"b":198},
                    {"a":255,"r":247,"g":150,"b":70},
                    {"a":255,"r":0,"g":0,"b":255},
                    {"a":255,"r":128,"g":0,"b":128}
                ]
            },
            "_headingFont":"Cambria",
            "_bodyFont":"Calibri"
        },
        "showRowRangeGroup":true,
        "showColumnRangeGroup":true,
        "rowRangeGroup":{//行的范围等属性
            "itemsCount":200,//单元格行数
            "itemsData":[],
            "direction":1,
            "head":null,
            "tail":null
        },
        "colRangeGroup":{//列的范围等属性
            "itemsCount":20,//单元格列数
            "itemsData":[],
            "direction":1,
            "head":null,
            "tail":null
        },
        "conditionalFormats":{
            "rules":[]
        },
        "sheetTabColor":null,//sheet的tab的背景颜色
        "frozenlineColor":"black",//冻结线的颜色
        "rowHeaderAutoText":1,
        "colHeaderAutoText":2,
        "rowHeaderAutoTextIndex":-1,
        "colHeaderAutoTextIndex":-1,
        "rowHeaderVisible":true,//是否显示行的索引
        "colHeaderVisible":true,//是否显示列的索引
        "rowHeaderColCount":1,//行索引列所占的列数
        "colHeaderRowCount":1,//列索引所占的行数
        "rowHeaderData":{//行索引的属性
            "rowCount":200,//行数
            "colCount":1,//列数
            "dataTable":{},
            "_rowDataArray":[],
            "_columnDataArray":[],
            "_defaultDataNode":{//默认索引项
                "style":{//默认索引项的属性
                    "foreColor":"#000000",//字体颜色
                    "hAlign":1,//水平对齐方式
                    "vAlign":1,//垂直对齐方式
                    "imeMode":1
                }
            }
        },
        "colHeaderData":{//列索引的属性
            "rowCount":1,//行数
            "colCount":20,//列数
            "dataTable":{},
            "_rowDataArray":[],
            "_columnDataArray":[],
            "_defaultDataNode":{
                "style":{
                    "foreColor":"#000000",
                    "hAlign":1,
                    "vAlign":1,
                    "imeMode":1
                }
            }
        },
        "rowHeaderSpan":[],//行索引合并信息
        "colHeaderSpan":[],//列索引合并信息
        "rowHeaderColInfos":[],
        "colHeaderRowInfos":[],
        "clipBoardOptions":0,
        "isProtected":false,
        "borderColor":"black",//单元格的边框颜色
        "borderWidth":0,//单元格的边框宽度
        "allowDragDrop":true,//是否允许拖动
        "allowDragFill":true,
        "allowUndo":true,
        "allowEditorReservedLocations":true,
        "tableManager":{
            "tables":[]
        },
        "floatingObjectArray":{
            "floatingObjects":[]
        },
        "names":[],
        "namedStyles":[],
        "visible":true,
        "_index":0
    },
    "Sheet2":{
        "name":"Sheet2",
        "defaults":{
            "rowHeight":20,
            "colWidth":62,
            "rowHeaderColWidth":40,
            "colHeaderRowHeight":20
        },
        "columns":[],
        "rows":[],
        "autoGenerateColumns":true,
        "dataBinding":null,
        "frozenRowCount":0,
        "frozenColCount":0,
        "frozenTrailingRowCount":0,
        "frozenTrailingColCount":0,
        "rowCount":200,
        "columnCount":20,
        "data":{
            "name":"Sheet2",
            "rowCount":200,
            "colCount":20,
            "dataTable":{
                "0":{
                    "0":{
                        "value":"db_a1",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "1":{
                        "value":"db_b1",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "2":{
                        "value":"db_c1",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "3":{
                        "value":"db_d1",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "4":{
                        "value":"db_e1",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "rs":"e"
                },
                "1":{
                    "0":{
                        "value":"db_a2",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "1":{
                        "value":"db_b2",
                        "style":{
                            "foreColor":"#000000",
                            "hAlign":3,
                            "vAlign":0,
                            "_autoFormatter":null,
                            "imeMode":1
                        }
                    },
                    "2":{
                        "value":"db_c2",
                        "style":{
                            "foreColor":"#000000",
                            "hAlign":3,
                            "vAlign":0,
                            "_autoFormatter":null,
                            "imeMode":1
                        }
                    },
                    "3":{
                        "value":"db_d2",
                        "style":{
                            "foreColor":"#000000",
                            "hAlign":3,
                            "vAlign":0,
                            "_autoFormatter":null,
                            "imeMode":1
                        }
                    },
                    "4":{
                        "value":"db_e2",
                        "style":{
                            "foreColor":"rgb(255, 0, 0)",
                            "hAlign":3,
                            "vAlign":0,
                            "_autoFormatter":null,
                            "imeMode":1
                        }
                    },
                    "rs":"e"
                },
                "2":{
                    "0":{
                        "value":"db_a3",
                        "style":{
                            "_autoFormatter":null
                        }
                    },
                    "1":{
                        "value":"db_b3",
                        "style":{
                            "foreColor":"#000000",
                            "hAlign":3,
                            "vAlign":0,
                            "_autoFormatter":null,
                            "imeMode":1
                        }
                    },
                    "2":{
                        "value":"db_c3",
                        "style":{
                            "foreColor":"#000000",
                            "hAlign":3,
                            "vAlign":0,
                            "_autoFormatter":null,
                            "imeMode":1
                        }
                    },
                    "3":{
                        "value":"db_d3",
                        "style":{
                            "foreColor":"#000000",
                            "hAlign":3,
                            "vAlign":0,
                            "_autoFormatter":null,
                            "imeMode":1
                        }
                    },
                    "4":{
                        "value":"db_e3",
                        "style":{
                            "foreColor":"#000000",
                            "hAlign":2,//文字水平对齐方式,0是居左,1是居中,2是居右
                            "vAlign":0,//文字垂直对齐方式,0是居下,1是居中,2是居上
                            "_autoFormatter":null,
                            "imeMode":1
                        }
                    },
                    "rs":"e"
                },
                "3":{
                    "0":{
                        "value":"db_a4",
                        "style":{
                            "_autoFormatter":null
                        }
                    },    
                    "1":{
                        "value":"db_b4",
                        "style":{
                            "foreColor":"#000000",
                            "hAlign":3,
                            "vAlign":0,
                            "_autoFormatter":null,
                            "imeMode":1
                        }
                    },
                    "2":{
                        "value":"db_c4",
                        "style":{
                            "foreColor":"#000000",
                            "hAlign":3,
                            "vAlign":0,
                            "_autoFormatter":null,
                            "imeMode":1
                        }    
                      },
                      "3":{
                          "value":"db_d4",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "4":{
                          "value":"db_e4",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":0,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "rs":"e"
                  },
                  "4":{
                      "0":{
                          "value":"db_a5",
                          "style":{
                              "_autoFormatter":null
                          }
                      },
                      "1":{
                          "value":"db_b5",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "2":{
                          "value":"db_c5",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "3":{
                          "value":"db_d5",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "4":{
                          "value":"db_e5",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "font":"normal normal bold 13px/normal Arial",//单元格的字体字号等。第三个是是否家族,第四个是大小,第五个是字体
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "rs":"e"
                  },
                  "5":{
                      "0":{
                          "value":"db_a6",
                          "style":{
                              "_autoFormatter":null
                          }
                      },
                      "1":{
                          "value":"db_b6",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "2":{
                          "value":"db_c6",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "3":{
                          "value":"db_d6",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "borderLeft":{
                                  "color":"black",
                                  "style":1
                              },
                              "borderTop":{
                                  "color":"black",
                                  "style":1
                              },
                              "borderRight":{
                                  "color":"black",
                                  "style":1
                              },
                              "borderBottom":{
                                  "color":"black",
                                  "style":1
                              },
                              "imeMode":1
                          }
                      },
                      "4":{
                          "value":"db_e6",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "font":"italic normal normal 13px/normal Arial",
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "rs":"e"
                  },
                  "6":{
                      "0":{
                          "value":"db_a1",
                          "style":{
                              "_autoFormatter":null,
                              "backColor":"rgb(255, 255, 0)"
                          }
                      },
                      "1":{
                          "value":"db_b7",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "2":{
                          "value":"db_c7",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "3":{
                          "value":"db_d7",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "imeMode":1
                          }
                      },
                      "4":{
                          "value":"db_e7",
                          "style":{
                              "foreColor":"#000000",
                              "hAlign":3,
                              "vAlign":0,
                              "_autoFormatter":null,
                              "borderBottom":{
                                  "color":"black",
                                  "style":1
                              },
                              "imeMode":1
                            }
                        },
                        "rs":"e"
                    }
                },
                "_rowDataArray":[],
                "_columnDataArray":[],
                "_defaultDataNode":{
                    "style":{
                        "foreColor":"#000000",
                        "hAlign":3,
                        "vAlign":0,
                        "imeMode":1
                    }
                }
            },
            "sparklineGroupManager":{
                "groups":[]
            },
            "spans":[],
            "selections":{
                "0":{
                    "row":4,
                    "rowCount":1,
                    "col":6,
                    "colCount":1
                },
                "selectionPolicy":2,
                "selectionUnit":0,
                "length":1,
                "activeSelectedRangeIndex":0
            },
            "selectionBackColor":"rgba(180,180,200,0.2)",
            "selectionBorderColor":"black",
            "activeRow":4,
            "activeCol":6,
            "gridline":{
                "color":"#d0d7e5",
                "showVerticalGridline":true,
                "showHorizontalGridline":true
            },
            "allowCellOverflow":false,
            "referenceStyle":0,
            "_zoomFactor":1,
            "theme":{
                "_name":"Office",
                "_themeColor":{
                    "_name":"Office",
                    "_colorList":[
                        {"a":255,"r":255,"g":255,"b":255},
                        {"a":255,"r":238,"g":236,"b":225},
                        {"a":255,"r":0,"g":0,"b":0},
                        {"a":255,"r":31,"g":73,"b":125},
                        {"a":255,"r":79,"g":129,"b":189},
                        {"a":255,"r":192,"g":80,"b":77},
                        {"a":255,"r":155,"g":187,"b":89},
                        {"a":255,"r":128,"g":100,"b":162},
                        {"a":255,"r":75,"g":172,"b":198},
                        {"a":255,"r":247,"g":150,"b":70},
                        {"a":255,"r":0,"g":0,"b":255},
                        {"a":255,"r":128,"g":0,"b":128}
                    ]
                },
                "_headingFont":"Cambria",
                "_bodyFont":"Calibri"
            },
            "showRowRangeGroup":true,
            "showColumnRangeGroup":true,
            "rowRangeGroup":{
                "itemsCount":200,
                "itemsData":[],
                "direction":1,
                "head":null,
                "tail":null
            },
            "colRangeGroup":{
                "itemsCount":20,
                "itemsData":[],
                "direction":1,
                "head":null,
                "tail":null
            },
            "conditionalFormats":{
                "rules":[]
            },
            "sheetTabColor":null,
            "frozenlineColor":"black",
            "rowHeaderAutoText":1,
            "colHeaderAutoText":2,
            "rowHeaderAutoTextIndex":-1,
            "colHeaderAutoTextIndex":-1,
            "rowHeaderVisible":true,
            "colHeaderVisible":true,
            "rowHeaderColCount":1,
            "colHeaderRowCount":1,
            "rowHeaderData":{
                "rowCount":200,
                "colCount":1,
                "dataTable":{},
                "_rowDataArray":[],
                "_columnDataArray":[],
                "_defaultDataNode":{
                    "style":{
                        "foreColor":"#000000",
                        "hAlign":1,
                        "vAlign":1,
                        "imeMode":1
                    }
                }
            },
            "colHeaderData":{
                "rowCount":1,
                "colCount":20,
                "dataTable":{},
                "_rowDataArray":[],
                "_columnDataArray":[],
                "_defaultDataNode":{
                    "style":{
                        "foreColor":"#000000",
                        "hAlign":1,
                        "vAlign":1,
                        "imeMode":1
                    }
                }
            },
            "rowHeaderSpan":[],
            "colHeaderSpan":[],
            "rowHeaderColInfos":[],
            "colHeaderRowInfos":[],
            "clipBoardOptions":0,
            "isProtected":false,
            "borderColor":"black",
            "borderWidth":0,
            "allowDragDrop":true,
            "allowDragFill":true,
            "allowUndo":true,
            "allowEditorReservedLocations":true,
            "tableManager":{
                "tables":[]
            },
            "floatingObjectArray":{
                "floatingObjects":[]
            },
            "names":[],
            "namedStyles":[],
            "visible":true,
            "_index":1
        }
    },
    "names":[],
    "showDragFillTip":true,
    "showHorizontalScrollbar":true,
    "showVerticalScrollbar":true,
    "backColor":"white",
    "backgroundImage":null,
    "backgroundImageLayout":0,
    "grayAreaBackColor":"gray",
    "namedStyles":[]
}




-----------------------------------------------------
转载请注明来源此处
原地址:#

-----网友评论----
1楼:fanxi 发表于 2016-07-21 09:42:51
楼主对前端很在行,点赞,补充下SpreadJS官网 http://www.gcpowertools.com.cn/products/spreadjs/
-----发表评论----
微网聚博客乐园 ©2014 blog.mn886.net 鲁ICP备14012923号   网站导航