diff --git a/src/controllers/constant.js b/src/controllers/constant.js
index fcbb23b..baf0077 100644
--- a/src/controllers/constant.js
+++ b/src/controllers/constant.js
@@ -230,9 +230,9 @@ const gridHTML = function(){
100%
diff --git a/src/controllers/print.js b/src/controllers/print.js
index e07d72e..e659280 100644
--- a/src/controllers/print.js
+++ b/src/controllers/print.js
@@ -1,4 +1,9 @@
-import { jsPDF } from "jspdf";
+import luckysheetConfigsetting from './luckysheetConfigsetting';
+import {zoomChange} from './zoom';
+import sheetmanage from './sheetmanage';
+import server from './server';
+import Store from '../store';
+// import { jsPDF } from "jspdf";
let ExcelPlaceholder = {
"[tabName]":"&A",
@@ -20,4 +25,78 @@ function getOneMmsPx (){
document.querySelector("body").appendChild(div);
let mm1 = document.getElementById("mm").getBoundingClientRect();
return mm1.width;
-}
\ No newline at end of file
+}
+
+export function viewChange(curType, preType){
+ let currentSheet = sheetmanage.getSheetByIndex();
+
+ if(currentSheet.config==null){
+ currentSheet.config = {};
+ }
+
+ if(currentSheet.config.sheetViewZoom==null){
+ currentSheet.config.sheetViewZoom = {};
+ }
+
+ let defaultZoom = 1, type="zoomScaleNormal";
+
+ if(curType=="viewNormal"){
+ type = "viewNormalZoomScale";
+ }
+ else if(curType=="viewLayout"){
+ type = "viewLayoutZoomScale";
+ }
+ else if(curType=="viewPage"){
+ type = "viewPageZoomScale";
+ defaultZoom = 0.6;
+ }
+
+ let curZoom = currentSheet.config.sheetViewZoom[type];
+ if(curZoom==null){
+ curZoom = defaultZoom;
+ }
+
+ currentSheet.config.curentsheetView = curType;
+
+ if (Store.clearjfundo) {
+ Store.jfredo.push({
+ "type": "viewChange",
+ "curType": curType,
+ "preType": preType,
+ "sheetIndex": Store.currentSheetIndex,
+ });
+ }
+
+ // Store.zoomRatio = curZoom;
+ // server.saveParam("all", Store.currentSheetIndex, curZoom, { "k": "zoomRatio" });
+ server.saveParam("cg", Store.currentSheetIndex, curType, { "k": "curentsheetView" });
+
+ zoomChange(curZoom);
+}
+
+function switchViewBtn($t){
+ let $viewList = $t.parent(), preType=$viewList.find("luckysheet-print-viewBtn-active").attr("type");
+ if($t.attr("type") == preType){
+ return;
+ }
+
+ let curType = $t.attr("type");
+ if(curType!=null){
+ viewChange(curType, preType);
+ }
+ else{
+ return;
+ }
+
+ $t.parent().find(".luckysheet-print-viewBtn").removeClass("luckysheet-print-viewBtn-active");
+ $t.addClass("luckysheet-print-viewBtn-active");
+}
+
+export function printInitial(){
+ let container = luckysheetConfigsetting.container;
+ let _this = this;
+ $("#"+container).find(".luckysheet-print-viewBtn").click(function(){
+ switchViewBtn($(this));
+ });
+
+}
\ No newline at end of file
diff --git a/src/controllers/zoom.js b/src/controllers/zoom.js
index a06df15..df50d37 100644
--- a/src/controllers/zoom.js
+++ b/src/controllers/zoom.js
@@ -1,6 +1,7 @@
import Store from '../store';
import locale from '../locale/locale';
import { replaceHtml } from '../utils/util';
+import sheetmanage from './sheetmanage';
import {changeSheetContainerSize} from './resize';
import { jfrefreshgrid_rhcw } from '../global/refresh';
import server from './server';
@@ -26,9 +27,25 @@ export function zoomChange(ratio){
}
Store.zoomRatio = ratio;
+
+ let currentSheet = sheetmanage.getSheetByIndex();
+ if(currentSheet.config==null){
+ currentSheet.config = {};
+ }
+
+ if(currentSheet.config.sheetViewZoom==null){
+ currentSheet.config.sheetViewZoom = {};
+ }
+
+ let type = currentSheet.config.curentsheetView;
+ if(type==null){
+ type = "viewNormal";
+ }
+ currentSheet.config.sheetViewZoom[type+"ZoomScale"] = ratio;
server.saveParam("all", Store.currentSheetIndex, Store.zoomRatio, { "k": "zoomRatio" });
-
+ server.saveParam("cg", Store.currentSheetIndex, currentSheet.config["sheetViewZoom"], { "k": "sheetViewZoom" });
+
zoomRefreshView();
}, 100);
diff --git a/src/core.js b/src/core.js
index ccbc140..3f9f945 100644
--- a/src/core.js
+++ b/src/core.js
@@ -30,6 +30,7 @@ import { getcellvalue, getdatabyselection } from './global/getdata';
import { setcellvalue } from './global/setdata';
import { selectHightlightShow } from './controllers/select';
import {zoomInitial} from './controllers/zoom';
+import {printInitial} from './controllers/print';
import method from './global/method';
import * as api from './global/api';
@@ -109,6 +110,7 @@ luckysheet.create = function (setting) {
luckysheetConfigsetting.defaultRowHeight = extendsetting.defaultRowHeight;
luckysheetConfigsetting.title = extendsetting.title;
+ luckysheetConfigsetting.container = extendsetting.container;
// Register plugins
initPlugins(extendsetting.plugins , extendsetting.data);
@@ -158,6 +160,7 @@ function initialWorkBook(){
keyboardInitial();//Keyboard operate initialization
orderByInitial();//menu bar orderby function initialization
zoomInitial();//zoom method initialization
+ printInitial();//print initialization
}
//获取所有表格数据
diff --git a/src/index.html b/src/index.html
index 899faf6..8d39c19 100644
--- a/src/index.html
+++ b/src/index.html
@@ -54,7 +54,7 @@
}
],
data:
- [sheetCell,sheetFormula,sheetConditionFormat,sheetSparkline,sheetTable,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart,sheetPicture,sheetDataVerification]
+ // [sheetCell,sheetFormula,sheetConditionFormat,sheetSparkline,sheetTable,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart,sheetPicture,sheetDataVerification]
/*[{"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":{
@@ -96,10 +96,16 @@
{"r":17,"c":2,"v":{"v":"Luckysheet","ct":{"fa":"General","t":"g"},"bg":null,"bl":0,"it":0,"ff":0,"fs":"11","fc":"rgb(51, 51, 51)","ht":1,"vt":1,"m":"Luckysheet"}}
],"calcChain":[]}]*/
- /*
+
[{
"name": "Cell",
"config": {
+ "curentsheetView":"viewNormal",//viewNormal, viewLayout, viewPage
+ "sheetViewZoom":{
+ "viewNormalZoomScale": 1 ,
+ "viewLayoutZoomScale":1 ,
+ "viewPageZoomScale":0.6,
+ },
"printoptions":{
unit:"mm",//mm(default), in, pt, cm, m,
PrintArea:"$A$1:$S$31",//print range
@@ -1776,7 +1782,7 @@
],
"scrollLeft": 0,
"scrollTop": 0
- }]*/
+ }]
})
})