forked from sheetjs/sheetjs
Freeze columns
This commit is contained in:
parent
a03dc219ab
commit
f2520b7223
@ -1 +1 @@
|
||||
XLSX.version = '0.8.17';
|
||||
XLSX.version = '0.8.20';
|
||||
|
@ -154,11 +154,19 @@ function write_wb_xml(wb, opts) {
|
||||
for(var i = 0; i != wb.SheetNames.length; ++i) {
|
||||
var sheetName = wb.SheetNames[i];
|
||||
var sheet = wb.Sheets[sheetName]
|
||||
if (sheet['!printHeader']) {
|
||||
if (sheet['!printHeader'] || sheet['!printColumns']) {
|
||||
var printHeader = sheet['!printHeader'];
|
||||
var printColumns = sheet['!printColumns'];
|
||||
|
||||
var range = "'" + sheetName + "'!$" + printHeader[0] + ":$" + printHeader[1];
|
||||
//Sheet1!$A:$C,Sheet1!$1:$1
|
||||
var range = "";
|
||||
|
||||
if (printColumns) range += ("'" + sheetName + "'!") + ("$" + printColumns[0] + ":$" + printColumns[1]);
|
||||
if (printColumns && printHeader) range += ","
|
||||
if (printHeader) range += ("'" + sheetName + "'!" ) + ("$" + printHeader[0] + ":$" + printHeader[1]);
|
||||
|
||||
console.log("-----------------------------")
|
||||
console.log(range)
|
||||
o[o.length] = (writextag('definedName', range, {
|
||||
"name":"_xlnm.Print_Titles",
|
||||
localSheetId : ''+i
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "js-xlsx",
|
||||
"homepage": "https://github.com/SheetJS/js-xlsx",
|
||||
"main": "dist/xlsx.js",
|
||||
"version": "0.8.17",
|
||||
"version": "0.8.20",
|
||||
"ignore": [
|
||||
"bin",
|
||||
"bits",
|
||||
|
12
dist/xlsx.core.min.js
vendored
12
dist/xlsx.core.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/xlsx.core.min.map
vendored
2
dist/xlsx.core.min.map
vendored
File diff suppressed because one or more lines are too long
12
dist/xlsx.full.min.js
vendored
12
dist/xlsx.full.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/xlsx.full.min.map
vendored
2
dist/xlsx.full.min.map
vendored
File diff suppressed because one or more lines are too long
14
dist/xlsx.js
vendored
14
dist/xlsx.js
vendored
@ -4,7 +4,7 @@
|
||||
/*jshint funcscope:true, eqnull:true */
|
||||
var XLSX = {};
|
||||
(function make_xlsx(XLSX){
|
||||
XLSX.version = '0.8.17';
|
||||
XLSX.version = '0.8.20';
|
||||
var current_codepage = 1200, current_cptable;
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
if(typeof cptable === 'undefined') cptable = require('./dist/cpexcel');
|
||||
@ -8664,11 +8664,19 @@ function write_wb_xml(wb, opts) {
|
||||
for(var i = 0; i != wb.SheetNames.length; ++i) {
|
||||
var sheetName = wb.SheetNames[i];
|
||||
var sheet = wb.Sheets[sheetName]
|
||||
if (sheet['!printHeader']) {
|
||||
if (sheet['!printHeader'] || sheet['!printColumns']) {
|
||||
var printHeader = sheet['!printHeader'];
|
||||
var printColumns = sheet['!printColumns'];
|
||||
|
||||
var range = "'" + sheetName + "'!$" + printHeader[0] + ":$" + printHeader[1];
|
||||
//Sheet1!$A:$C,Sheet1!$1:$1
|
||||
var range = "";
|
||||
|
||||
if (printColumns) range += ("'" + sheetName + "'!") + ("$" + printColumns[0] + ":$" + printColumns[1]);
|
||||
if (printColumns && printHeader) range += ","
|
||||
if (printHeader) range += ("'" + sheetName + "'!" ) + ("$" + printHeader[0] + ":$" + printHeader[1]);
|
||||
|
||||
console.log("-----------------------------")
|
||||
console.log(range)
|
||||
o[o.length] = (writextag('definedName', range, {
|
||||
"name":"_xlnm.Print_Titles",
|
||||
localSheetId : ''+i
|
||||
|
10
dist/xlsx.min.js
vendored
10
dist/xlsx.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/xlsx.min.map
vendored
2
dist/xlsx.min.map
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xlsx",
|
||||
"version": "0.8.18",
|
||||
"version": "0.8.20",
|
||||
"author": "sheetjs",
|
||||
"description": "Excel (XLSB/XLSX/XLSM/XLS/XML) and ODS spreadsheet parser and writer (extended to enable read/write of cell formats with xlsx files)",
|
||||
"keywords": [ "excel", "xls", "xlsx", "xlsb", "xlsm", "ods", "office", "spreadsheet" ],
|
||||
|
48
tests/print-header.js
Normal file
48
tests/print-header.js
Normal file
@ -0,0 +1,48 @@
|
||||
var XLSX = require('../.');
|
||||
|
||||
var JSZip = require('jszip');
|
||||
var fs = require('fs');
|
||||
var cheerio = require('cheerio');
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
function JSDateToExcelDate(inDate) {
|
||||
return 25569.0 + ((inDate.getTime() - (inDate.getTimezoneOffset() * 60 * 1000)) / (1000 * 60 * 60 * 24));
|
||||
}
|
||||
|
||||
var defaultCellStyle = { font: { name: "Verdana", sz: 11, color: "FF00FF88"}, fill: {fgColor: {rgb: "FFFFAA00"}}};
|
||||
|
||||
|
||||
|
||||
describe('repeats header', function () {
|
||||
it ('repeats header', function() {
|
||||
|
||||
|
||||
var workbook = {
|
||||
SheetNames: ["Sheet1"],
|
||||
Sheets: {
|
||||
"Sheet1": {
|
||||
"!ref":"A1:Z99",
|
||||
"!printHeader":[1,1],
|
||||
"!printColumns":["A","C"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".split('').forEach(function(c) {
|
||||
for (var i=1; i<100; i++) {
|
||||
var address = c + i;
|
||||
|
||||
workbook.Sheets.Sheet1[address] = {v: address};
|
||||
}
|
||||
})
|
||||
var OUTFILE = '/tmp/header.xlsx';
|
||||
var OUTFILE = __dirname + '/../lab/headers/header.xlsx';
|
||||
|
||||
|
||||
// write the file and read it back...
|
||||
XLSX.writeFile(workbook, OUTFILE, {bookType: 'xlsx', bookSST: false});
|
||||
console.log("open \""+OUTFILE+"\"")
|
||||
});
|
||||
});
|
||||
|
@ -1,98 +0,0 @@
|
||||
var XLSX = require('../.');
|
||||
|
||||
var JSZip = require('jszip');
|
||||
var fs = require('fs');
|
||||
var cheerio = require('cheerio');
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
function JSDateToExcelDate(inDate) {
|
||||
return 25569.0 + ((inDate.getTime() - (inDate.getTimezoneOffset() * 60 * 1000)) / (1000 * 60 * 60 * 24));
|
||||
}
|
||||
|
||||
var defaultCellStyle = { font: { name: "Verdana", sz: 11, color: "FF00FF88"}, fill: {fgColor: {rgb: "FFFFAA00"}}};
|
||||
//"A1": {v: "Header", s: { border: { top: { style: 'medium', color: { rgb: "FFFFAA00"}}, left: { style: 'medium', color: { rgb: "FFFFAA00"}} }}},
|
||||
|
||||
|
||||
var workbook = {
|
||||
SheetNames : ["Sheet1"],
|
||||
Sheets: {
|
||||
"Sheet1": {
|
||||
"A1": {v: "Header"},
|
||||
"A2": {v: "Anchorage"},
|
||||
"A3": {v: "Anchorage"},
|
||||
"A4": {v: "Boston"},
|
||||
"A5": {v: "Chicago"},
|
||||
"A6": {v: "Dayton"},
|
||||
"A7": {v: "East Lansing"},
|
||||
"A8": {v: "Fargo"},
|
||||
"A9": {v: "Galena"},
|
||||
"A10": {v: "Iowa City"},
|
||||
"A11": {v: "Jacksonville"},
|
||||
"A12": {v: "Jacksonville"},
|
||||
"A13": {v: "Jacksonville"},
|
||||
"A14": {v: "Jacksonville"},
|
||||
"A15": {v: "Jacksonville"},
|
||||
"A16": {v: "Jacksonville"},
|
||||
"A17": {v: "Jacksonville"},
|
||||
"A18": {v: "Jacksonville"},
|
||||
"A19": {v: "Jacksonville"},
|
||||
"A20": {v: "Jacksonville"},
|
||||
"A21": {v: "Jacksonville"},
|
||||
"A22": {v: "Jacksonville"},
|
||||
"A23": {v: "Jacksonville"},
|
||||
"A24": {v: "Jacksonville"},
|
||||
"A25": {v: "Jacksonville"},
|
||||
"A26": {v: "Jacksonville"},
|
||||
"A27": {v: "Jacksonville"},
|
||||
"A28": {v: "Jacksonville"},
|
||||
"A29": {v: "Jacksonville"},
|
||||
"A30": {v: "Jacksonville"},
|
||||
"A31": {v: "Jacksonville"},
|
||||
"A32": {v: "Jacksonville"},
|
||||
"A33": {v: "Jacksonville"},
|
||||
"A34": {v: "Jacksonville"},
|
||||
"A35": {v: "Jacksonville"},
|
||||
"A36": {v: "Jacksonville"},
|
||||
"A37": {v: "Jacksonville"},
|
||||
"A38": {v: "Jacksonville"},
|
||||
"A39": {v: "Jacksonville"},
|
||||
"A40": {v: "Jacksonville"},
|
||||
"A41": {v: "Jacksonville"},
|
||||
"A42": {v: "Jacksonville"},
|
||||
"A43": {v: "Jacksonville"},
|
||||
"A44": {v: "Jacksonville"},
|
||||
"A45": {v: "Jacksonville"},
|
||||
"A46": {v: "Jacksonville"},
|
||||
"A47": {v: "Jacksonville"},
|
||||
"A48": {v: "Jacksonville"},
|
||||
"A49": {v: "Jacksonville"},
|
||||
"A50": {v: "Jacksonville"},
|
||||
"A51": {v: "Jacksonville"},
|
||||
"A52": {v: "Jacksonville"},
|
||||
"A53": {v: "Jacksonville"},
|
||||
"A54": {v: "Jacksonville"},
|
||||
"A55": {v: "Jacksonville"},
|
||||
"A56": {v: "Jacksonville"},
|
||||
"A57": {v: "Jacksonville"},
|
||||
"A58": {v: "Jacksonville"},
|
||||
"A59": {v: "Jacksonville"},
|
||||
"!ref":"A1:A59",
|
||||
"!printHeader":[1,1]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
describe('repeats header', function () {
|
||||
it ('repeats header', function() {
|
||||
|
||||
|
||||
var OUTFILE = '/tmp/header.xlsx';
|
||||
|
||||
|
||||
// write the file and read it back...
|
||||
XLSX.writeFile(workbook, OUTFILE, {bookType: 'xlsx', bookSST: false});
|
||||
console.log("open \""+OUTFILE+"\"")
|
||||
});
|
||||
});
|
||||
|
14
xlsx.js
14
xlsx.js
@ -4,7 +4,7 @@
|
||||
/*jshint funcscope:true, eqnull:true */
|
||||
var XLSX = {};
|
||||
(function make_xlsx(XLSX){
|
||||
XLSX.version = '0.8.17';
|
||||
XLSX.version = '0.8.20';
|
||||
var current_codepage = 1200, current_cptable;
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
if(typeof cptable === 'undefined') cptable = require('./dist/cpexcel');
|
||||
@ -8664,11 +8664,19 @@ function write_wb_xml(wb, opts) {
|
||||
for(var i = 0; i != wb.SheetNames.length; ++i) {
|
||||
var sheetName = wb.SheetNames[i];
|
||||
var sheet = wb.Sheets[sheetName]
|
||||
if (sheet['!printHeader']) {
|
||||
if (sheet['!printHeader'] || sheet['!printColumns']) {
|
||||
var printHeader = sheet['!printHeader'];
|
||||
var printColumns = sheet['!printColumns'];
|
||||
|
||||
var range = "'" + sheetName + "'!$" + printHeader[0] + ":$" + printHeader[1];
|
||||
//Sheet1!$A:$C,Sheet1!$1:$1
|
||||
var range = "";
|
||||
|
||||
if (printColumns) range += ("'" + sheetName + "'!") + ("$" + printColumns[0] + ":$" + printColumns[1]);
|
||||
if (printColumns && printHeader) range += ","
|
||||
if (printHeader) range += ("'" + sheetName + "'!" ) + ("$" + printHeader[0] + ":$" + printHeader[1]);
|
||||
|
||||
console.log("-----------------------------")
|
||||
console.log(range)
|
||||
o[o.length] = (writextag('definedName', range, {
|
||||
"name":"_xlnm.Print_Titles",
|
||||
localSheetId : ''+i
|
||||
|
Loading…
Reference in New Issue
Block a user