概述
本 Demo 演示如何通过页面面板动态修改工作表打印设置。用户可以调整打印区域、重复行列、行列头显示、纸张大小、页眉页脚、水印和打印线可见性,然后应用到当前工作表。
实现思路
加载预设数据,并设置默认打印信息。
把当前 printInfo 配置同步到右侧表单。
用户点击“设置打印信息”时,将表单值写回 printInfo。
用户可以添加或清空水印,也可以单独控制打印线显示。
点击“打印”按钮时调用 spread.print(0) 打印第一个工作表。
代码解析
初始化阶段先设置默认打印范围、重复行和行列头显示方式,让工作簿打开后已有一套可用的打印配置。
点击应用按钮时,页眉页脚表单会被组装成 pageHeaderFooter 配置写回打印信息。代码还同时支持首页、奇数页和偶数页的不同页眉页脚设置。
水印配置来自面板输入项,包含位置、尺寸、图片地址和应用页面;最终通过 printInfo.watermark(...) 写入打印配置。
运行效果
右侧面板可以调整打印区域、重复区域和打印选项。
可以配置常规、首页、奇数页和偶数页的页眉页脚。
可以添加图片水印,并指定水印出现的页面。
勾选打印线后,工作表中会显示打印区域辅助线。
点击“打印”会按当前配置打开打印流程。
API 参考
sheet.printInfo():读取和设置工作表打印信息。
printInfo.pageHeaderFooter(...):设置页眉和页脚。
printInfo.watermark(...):设置打印水印。
sheet.isPrintLineVisible(...):控制工作表中的打印线显示。
spread.print(0):打印指定工作表。
function _getElementById(id) {
return document.getElementById(id);
}
function _getElementByClass(className) {
return document.getElementsByClassName(className);
}
var PAPER_SIZE_KINDS = ["1", "3", "5", "6", "7", "8", "9", "11"];
function setDefaultPaperKindForCurrentCulture() {
var cultureName = GC.Spread.Common.CultureManager.culture();
if (cultureName === "zh-cn" || cultureName === "ja-jp" || cultureName === "ko-kr") {
GC.Spread.Common.CultureManager.getCultureInfo().paperKind = GC.Spread.Sheets.Print.PaperKind.a4;
}
}
function getDefaultPaperSizeKind() {
return GC.Spread.Sheets.Print.PaperKind.letter.toString();
}
function normalizePaperSizeKind(kind) {
var kindString = kind == null ? getDefaultPaperSizeKind() : kind.toString();
return PAPER_SIZE_KINDS.indexOf(kindString) >= 0 ? kindString : getDefaultPaperSizeKind();
}
window.onload = function () {
setDefaultPaperKindForCurrentCulture();
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 1 });
initSpread(spread);
_getElementById('btnSetPrintInfo').addEventListener("click", setPrintInfo);
_getElementById('btnPrint').addEventListener("click", function () {
spread.print(0);
});
_getElementById('waterMarkAdd').addEventListener("click", addWaterMark);
_getElementById('waterMarkClear').addEventListener("click", function () {
var listDiv = _getElementById('waterMarkList');
listDiv.innerHTML = "";
listDiv.waterMarkList = [];
});
_getElementById('displayPrintLine').addEventListener("click", function () {
var sheet = spread.getActiveSheet();
sheet.isPrintLineVisible(_getElementById('displayPrintLine').checked);
});
_getElementById('selectTypeHeaderFooter').addEventListener("change", function (e) {
var type = parseInt(e.target.value)
var types = _getElementByClass('headfooter');
var diffFirst = _getElementByClass('differentFirstPage').item(0);
var diffOddEven = _getElementByClass('differentOddAndEvenPages').item(0);
if (type === 1) {
diffFirst.className = diffFirst.className.replace(/hidden/g, '');
} else {
diffFirst.className += " hidden";
}
if (type === 2 || type === 3) {
diffOddEven.className = diffOddEven.className.replace(/hidden/g, '');
} else {
diffOddEven.className += " hidden";
}
for (let index = 0; index < types.length; index++) {
const node = types[index];
if (node.className.indexOf('hidden')==-1) {
node.className += " hidden";
}
if (node.children.item(1).className.indexOf('hidden')==-1) {
node.children.item(1).className += " hidden";
}
if (type === index) {
node.className = node.className.replace(/hidden/g, '');
}
}
});
var titles = _getElementByClass('title');
for(var i=0; i<titles.length; i++){
titles[i].addEventListener("click", toggleClass);
}
}
function initSpread(spread) {
var sd = data;
if (sd && sd.sheets) {
if (!spread) {
return;
}
spread.suspendPaint();
spread.fromJSON(sd);
var sheet = spread.sheets[0];
adjustLayoutForPrint(sheet);
sheet.options.gridline.showVerticalGridline = false;
sheet.options.gridline.showHorizontalGridline = false;
initPrintInfo(sheet);
spread.resumePaint();
}
}
function initPrintInfo(sheet) {
var printInfo = sheet.printInfo();
// custom printInfo for default output
printInfo.showBorder(false);
printInfo.showGridLine(false);
printInfo.columnStart(1);
printInfo.columnEnd(6);
printInfo.rowStart(1);
printInfo.repeatRowStart(1);
printInfo.repeatRowEnd(2);
printInfo.showColumnHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
printInfo.showRowHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
printInfo.pageHeaderFooter({
normal: {
header: {
left: "&G",
center: "Olympic Athletes",
leftImage: "$DEMOROOT$/spread/source/images/olympic.jpg"
},
footer: {
center: "&P/&N"
}
}
});
// sync with UI setting items
_getElementById('rowStart').value = printInfo.rowStart();
_getElementById('rowEnd').value = printInfo.rowEnd();
_getElementById('columnStart').value = printInfo.columnStart();
_getElementById('columnEnd').value = printInfo.columnEnd();
_getElementById('repeatRowStart').value = printInfo.repeatRowStart();
_getElementById('repeatRowEnd').value = printInfo.repeatRowEnd();
_getElementById('repeatColumnStart').value = printInfo.repeatColumnStart();
_getElementById('repeatColumnEnd').value = printInfo.repeatColumnEnd();
_getElementById('showBorder').checked = printInfo.showBorder();
_getElementById('showGridLine').checked = printInfo.showGridLine();
_getElementById('displayPrintLine').checked = sheet.isPrintLineVisible();
_getElementById('showRowHeader').value = printInfo.showRowHeader();
_getElementById('showColumnHeader').value = printInfo.showColumnHeader();
_getElementById('paperSizeKind').value = normalizePaperSizeKind(printInfo.paperSize().kind());
var headerFooter = printInfo.pageHeaderFooter();
var normal = headerFooter.normal;
_getElementById('headerLeft').value = normal.header.left;
_getElementById('headerLeftImage').selected = normal.header.leftImage;
_getElementById('headerCenter').value = normal.header.center;
_getElementById('headerCenterImage').selected = normal.header.centerImage;
_getElementById('headerRight').value = normal.header.right || '';
_getElementById('headerRightImage').selected = normal.header.rightImage;
_getElementById('footerLeft').value = normal.footer.left || '';
_getElementById('footerLeftImage').selected = normal.footer.leftImage;
_getElementById('footerCenter').value = normal.footer.center;
_getElementById('footerCenterImage').selected = normal.footer.centerImage;
_getElementById('footerRight').value = normal.footer.right || '';
_getElementById('footerRightImage').selected = normal.footer.rightImage;
}
function setPrintInfo(){
function setPrintInfoNumberValueItem(printInfo, key, method) {
var value = parseInt(_getElementById(key).value),
method = method || key;
if (!isNaN(value)) {
printInfo[method](value);
}
}
var spread = GC.Spread.Sheets.findControl("ss");
var sheet = spread.getActiveSheet(),
printInfo = sheet.printInfo();
sheet.suspendPaint();
["rowStart", "rowEnd", "columnStart", "columnEnd",
"repeatRowStart", "repeatRowEnd", "repeatColumnStart", "repeatColumnEnd"
].forEach(function (name) {
setPrintInfoNumberValueItem(printInfo, name);
});
printInfo.showBorder(_getElementById('showBorder').checked);
printInfo.showGridLine(_getElementById('showGridLine').checked);
printInfo.showRowHeader(parseInt(_getElementById('showRowHeader').value));
printInfo.showColumnHeader(parseInt(_getElementById('showColumnHeader').value));
printInfo.paperSize().kind(parseInt(_getElementById('paperSizeKind').value, 10));
printInfo.pageHeaderFooter({
normal: {
header: {
left: _getElementById('headerLeft').value,
leftImage: _getElementById('headerLeftImage').value,
center: _getElementById('headerCenter').value,
centerImage: _getElementById('headerCenterImage').value,
right: _getElementById('headerRight').value,
rightImage: _getElementById('headerRightImage').value,
},
footer: {
left: _getElementById('footerLeft').value,
leftImage: _getElementById('footerLeftImage').value,
center: _getElementById('footerCenter').value,
centerImage: _getElementById('footerCenterImage').value,
right: _getElementById('footerRight').value,
rightImage: _getElementById('footerRightImage').value,
}
},
first: {
header: {
left: _getElementById('headerLeftOfFirstPage').value,
leftImage: _getElementById('headerLeftImageOfFirstPage').value,
center: _getElementById('headerCenterOfFirstPage').value,
centerImage: _getElementById('headerCenterImageOfFirstPage').value,
right: _getElementById('headerRightOfFirstPage').value,
rightImage: _getElementById('headerRightImageOfFirstPage').value,
},
footer: {
left: _getElementById('footerLeftOfFirstPage').value,
leftImage: _getElementById('footerLeftImageOfFirstPage').value,
center: _getElementById('footerCenterOfFirstPage').value,
centerImage: _getElementById('footerCenterImageOfFirstPage').value,
right: _getElementById('footerRightOfFirstPage').value,
rightImage: _getElementById('footerRightImageOfFirstPage').value,
}
},
odd: {
header: {
left: _getElementById('headerLeftOfOddPages').value,
leftImage: _getElementById('headerLeftImageOfOddPages').value,
center: _getElementById('headerCenterOfOddPages').value,
centerImage: _getElementById('headerCenterImageOfOddPages').value,
right: _getElementById('headerRightOfOddPages').value,
rightImage: _getElementById('headerRightImageOfOddPages').value,
},
footer: {
left: _getElementById('footerLeftOfOddPages').value,
leftImage: _getElementById('footerLeftImageOfOddPages').value,
center: _getElementById('footerCenterOfOddPages').value,
centerImage: _getElementById('footerCenterImageOfOddPages').value,
right: _getElementById('footerRightOfOddPages').value,
rightImage: _getElementById('footerRightImageOfOddPages').value,
}
},
even: {
header: {
left: _getElementById('headerLeftOfEvenPages').value,
leftImage: _getElementById('headerLeftImageOfEvenPages').value,
center: _getElementById('headerCenterOfEvenPages').value,
centerImage: _getElementById('headerCenterImageOfEvenPages').value,
right: _getElementById('headerRightOfEvenPages').value,
rightImage: _getElementById('headerRightImageOfEvenPages').value,
},
footer: {
left: _getElementById('footerLeftOfEvenPages').value,
leftImage: _getElementById('footerLeftImageOfEvenPages').value,
center: _getElementById('footerCenterOfEvenPages').value,
centerImage: _getElementById('footerCenterImageOfEvenPages').value,
right: _getElementById('footerRightOfEvenPages').value,
rightImage: _getElementById('footerRightImageOfEvenPages').value,
}
}
});
printInfo.differentFirstPage(_getElementById('differentFirstPage').checked);
printInfo.differentOddAndEvenPages(_getElementById('differentOddAndEvenPages').checked);
printInfo.watermark(_getElementById('waterMarkList').waterMarkList);
sheet.resumePaint();
}
function addWaterMark() {
var watermark = {};
watermark.x = _getElementById('waterMarkX').value;
watermark.y = _getElementById('waterMarkY').value;
watermark.width = _getElementById('waterMarkWidth').value;
watermark.height = _getElementById('waterMarkHeight').value;
watermark.imageSrc = _getElementById('waterMarkImage').value;
watermark.page = _getElementById('waterMarkPage').value;
var node=document.createElement("option");
node.innerText = JSON.stringify(Object.values(watermark));
var listDiv = _getElementById('waterMarkList');
listDiv.appendChild(node);
if (!listDiv.waterMarkList) {
listDiv.waterMarkList = [];
}
listDiv.waterMarkList.push(watermark);
}
function toggleClass() {
var node = this.nextElementSibling;
var reg = new RegExp('(\\s|^)hidden(\\s|$)');
while (node && node.className.indexOf("row title") === -1 && node.className.indexOf("btn-set") === -1) {
if (node.className.match(reg)) {
node.className = node.className.replace(reg, '');
} else {
node.className += " hidden";
}
node = node.nextElementSibling;
}
}
function adjustLayoutForPrint(sheet) {
sheet.addColumns(0, 2);
sheet.setColumnWidth(0, 30);
sheet.setColumnWidth(1, 30);
for (var r = 5; r <= 200; r += 5) {
sheet.getCell(r, 1).text(r + "").font("normal 9px Arial");
}
sheet.addRows(0, 2);
sheet.setRowHeight(0, 10);
sheet.setRowHeight(1, 10);
}
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta name="spreadjs culture" content="zh-cn" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css"
href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js"
type="text/javascript"></script>
<script
src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-print/dist/gc.spread.sheets.print.min.js"
type="text/javascript"></script>
<script
src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.min.js"
type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/data/customPrint.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="sample-tutorial">
<div id="ss" class="sample-spreadsheets"></div>
<aside class="options-container" aria-label="Custom Print Settings">
<div class="container">
<div class="row">
<span>更改这些选项并向下滚动,点击“设置打印信息”按钮将这些选项设置到 Spread 组件的打印信息中。点击“打印”按钮查看这些设置如何影响工作簿的打印效果。</span>
<hr style="border: 1px solid white;border-bottom-color: lightgray;" />
<div class="group">
<label>
<input type="checkbox" id="displayPrintLine">
打印线可见
</label>
</div>
</div>
<div class="row title">
<span>打印区域</span>
</div>
<div class="row hidden">
<div class="group">
<label>打印区域开始行:</label>
<input id="rowStart">
</div>
<div class="group">
<label>打印区域结束行:</label>
<input id="rowEnd">
</div>
<div class="group">
<label>打印区域开始列:</label>
<input id="columnStart">
</div>
<div class="group">
<label>打印区域结束列:</label>
<input id="columnEnd">
</div>
</div>
<div class="row title">
<span>重复打印区域</span>
</div>
<div class="row hidden">
<div class="group">
<label>重复打印区域开始行:</label>
<input id="repeatRowStart">
</div>
<div class="group">
<label>重复打印区域结束行:</label>
<input id="repeatRowEnd">
</div>
<div class="group">
<label>重复打印区域开始列:</label>
<input id="repeatColumnStart">
</div>
<div class="group">
<label>重复打印区域结束列:</label>
<input id="repeatColumnEnd">
</div>
</div>
<div class="row title">
<span>打印选项</span>
</div>
<div class="row hidden">
<div class="group">
<label>
<input type="checkbox" id="showBorder">
打印边框
</label>
</div>
<div class="group">
<label>
<input type="checkbox" id="showGridLine">
打印网格线
</label>
</div>
<div class="group">
<label>打印行标题:</label>
<select id="showRowHeader">
<option value="0">继承</option>
<option value="1">隐藏</option>
<option value="2">显示</option>
<option value="3">仅显示一次</option>
</select>
</div>
<div class="group">
<label>打印列标题:</label>
<select id="showColumnHeader">
<option value="0">继承</option>
<option value="1">隐藏</option>
<option value="2">显示</option>
<option value="3">仅显示一次</option>
</select>
</div>
</div>
<div class="row title">
<span>纸张尺寸</span>
</div>
<div class="row hidden">
<div class="group">
<label>纸张类型:</label>
<select id="paperSizeKind">
<option value="1">Letter</option>
<option value="3">Tabloid</option>
<option value="5">Legal</option>
<option value="6">Statement</option>
<option value="7">Executive</option>
<option value="8">A3</option>
<option value="9">A4</option>
<option value="11">A5</option>
</select>
</div>
</div>
<div class="row title">
<span>页眉页脚</span>
</div>
<div class="row hidden">
<div class="group">
<label>选择页眉页脚类型:</label>
<select id="selectTypeHeaderFooter">
<option value="0">普通</option>
<option value="1">第一页</option>
<option value="2">奇数页</option>
<option value="3">偶数页</option>
</select>
</div>
<div class="group differentFirstPage hidden">
<label>
<input type="checkbox" id="differentFirstPage">
启用不同第一页
</label>
</div>
<div class="group differentOddAndEvenPages hidden">
<label>
<input type="checkbox" id="differentOddAndEvenPages">
启用不同奇数页和偶数页
</label>
</div>
<div class="group headfooter">
<div class="row title">
<span>页眉</span>
</div>
<div class="row hidden">
<div class="group">
<label>页眉左:</label>
<input id="headerLeft">
</div>
<div class="group">
<label>页眉左图片:</label>
<select id="headerLeftImage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg" selected>Olympic
</option>
</select>
</div>
<div class="group">
<label>页眉中:</label>
<input id="headerCenter">
</div>
<div class="group">
<label>页眉中图片:</label>
<select id="headerCenterImage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页眉右:</label>
<input type="text" id="headerRight">
</div>
<div class="group">
<label>页眉右图片:</label>
<select id="headerRightImage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
</div>
<div class="row title">
<span>页脚</span>
</div>
<div class="row hidden">
<div class="group">
<label>页脚左:</label>
<input id="footerLeft">
</div>
<div class="group">
<label>页脚左图片:</label>
<select id="footerLeftImage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页脚中:</label>
<input id="footerCenter">
</div>
<div class="group">
<label>页脚中图片:</label>
<select id="footerCenterImage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页脚右:</label>
<input type="text" id="footerRight">
</div>
<div class="group">
<label>页脚右图片:</label>
<select id="footerRightImage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
</div>
</div>
<div class="group headfooter hidden">
<div class="row title">
<span>页眉</span>
</div>
<div class="row hidden">
<div class="group">
<label>页眉左:</label>
<input id="headerLeftOfFirstPage">
</div>
<div class="group">
<label>页眉左图片:</label>
<select id="headerLeftImageOfFirstPage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页眉中:</label>
<input id="headerCenterOfFirstPage">
</div>
<div class="group">
<label>页眉中图片:</label>
<select id="headerCenterImageOfFirstPage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页眉右:</label>
<input type="text" id="headerRightOfFirstPage">
</div>
<div class="group">
<label>页眉右图片:</label>
<select id="headerRightImageOfFirstPage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
</div>
<div class="row title">
<span>页脚</span>
</div>
<div class="row hidden">
<div class="group">
<label>页脚左:</label>
<input id="footerLeftOfFirstPage">
</div>
<div class="group">
<label>页脚左图片:</label>
<select id="footerLeftImageOfFirstPage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页脚中:</label>
<input id="footerCenterOfFirstPage">
</div>
<div class="group">
<label>页脚中图片:</label>
<select id="footerCenterImageOfFirstPage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页脚右:</label>
<input type="text" id="footerRightOfFirstPage">
</div>
<div class="group">
<label>页脚右图片:</label>
<select id="footerRightImageOfFirstPage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
</div>
</div>
<div class="group headfooter hidden">
<div class="row title">
<span>页眉</span>
</div>
<div class="row hidden">
<div class="group">
<label>页眉左:</label>
<input id="headerLeftOfOddPages">
</div>
<div class="group">
<label>页眉左图片:</label>
<select id="headerLeftImageOfOddPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页眉中:</label>
<input id="headerCenterOfOddPages">
</div>
<div class="group">
<label>页眉中图片:</label>
<select id="headerCenterImageOfOddPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页眉右:</label>
<input type="text" id="headerRightOfOddPages">
</div>
<div class="group">
<label>页眉右图片:</label>
<select id="headerRightImageOfOddPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
</div>
<div class="row title">
<span>页脚</span>
</div>
<div class="row hidden">
<div class="group">
<label>页脚左:</label>
<input id="footerLeftOfOddPages">
</div>
<div class="group">
<label>页脚左图片:</label>
<select id="footerLeftImageOfOddPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页脚中:</label>
<input id="footerCenterOfOddPages">
</div>
<div class="group">
<label>页脚中图片:</label>
<select id="footerCenterImageOfOddPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页脚右:</label>
<input type="text" id="footerRightOfOddPages">
</div>
<div class="group">
<label>页脚右图片:</label>
<select id="footerRightImageOfOddPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
</div>
</div>
<div class="group headfooter hidden">
<div class="row title">
<span>页眉</span>
</div>
<div class="row hidden">
<div class="group">
<label>页眉左:</label>
<input id="headerLeftOfEvenPages">
</div>
<div class="group">
<label>页眉左图片:</label>
<select id="headerLeftImageOfEvenPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页眉中:</label>
<input id="headerCenterOfEvenPages">
</div>
<div class="group">
<label>页眉中图片:</label>
<select id="headerCenterImageOfEvenPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页眉右:</label>
<input type="text" id="headerRightOfEvenPages">
</div>
<div class="group">
<label>页眉右图片:</label>
<select id="headerRightImageOfEvenPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
</div>
<div class="row title">
<span>页脚</span>
</div>
<div class="row hidden">
<div class="group">
<label>页脚左:</label>
<input id="footerLeftOfEvenPages">
</div>
<div class="group">
<label>页脚左图片:</label>
<select id="footerLeftImageOfEvenPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页脚中:</label>
<input id="footerCenterOfEvenPages">
</div>
<div class="group">
<label>页脚中图片:</label>
<select id="footerCenterImageOfEvenPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>页脚右:</label>
<input type="text" id="footerRightOfEvenPages">
</div>
<div class="group">
<label>页脚右图片:</label>
<select id="footerRightImageOfEvenPages">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
</div>
</div>
</div>
<div class="row title">
<span>水印</span>
</div>
<div class="row hidden">
<div class="group">
<label>X:</label>
<input type="number" id="waterMarkX">
</div>
<div class="group">
<label>Y:</label>
<input type="number" id="waterMarkY">
</div>
<div class="group">
<label>宽度:</label>
<input type="number" id="waterMarkWidth">
</div>
<div class="group">
<label>高度:</label>
<input type="number" id="waterMarkHeight">
</div>
<div class="group">
<label>水印图片:</label>
<select id="waterMarkImage">
<option value=""></option>
<option value="$DEMOROOT$/spread/source/images/apple.jpg">Apple</option>
<option value="$DEMOROOT$/spread/source/images/olympic.jpg">Olympic</option>
</select>
</div>
<div class="group">
<label>水印页面:</label>
<input type="text" id="waterMarkPage" list="list">
<datalist id="list">
<option value="all"></option>
<option value="odd"></option>
<option value="even"></option>
</datalist>
</div>
<div class="group">
<button type="button" id="waterMarkAdd" class="waterMark-btn">
添加
</button>
<button type="button" id="waterMarkClear" class="waterMark-btn">
清除
</button>
</div>
<div class="group">
<label>水印列表:</label>
<select id="waterMarkList" class="custom-list-pane" size="4"></select>
</div>
</div>
<div class="btn-set">
<input type="button" id="btnSetPrintInfo" value="设置打印信息">
</div>
<hr class="btn-set" style="border: 1px solid white;border-bottom-color: lightgray;" />
<div class="btn-set">
<input type="button" style="margin-bottom: 6px" value="打印" id="btnPrint">
</div>
</div>
</aside>
</div>
</body>
</html>
html,
body {
height: 100%;
margin: 0;
}
body {
position: absolute;
inset: 0;
color: #1f2933;
background: #f7f8fa;
}
body > iframe[role="none"] {
position: fixed !important;
top: 0 !important;
left: 0 !important;
width: 0 !important;
height: 0 !important;
border: 0 !important;
}
.sample-tutorial {
display: flex;
height: 100%;
overflow: hidden;
background: #f7f8fa;
}
.sample-spreadsheets {
flex: 1 1 auto;
min-width: 0;
height: 100%;
overflow: hidden;
}
.options-container {
flex: 0 0 320px;
width: 320px;
height: 100%;
box-sizing: border-box;
overflow: auto;
color: #1f2933;
background: #ffffff;
border-left: 1px solid #e5e7eb;
}
.options-container .container {
width: 100%;
min-height: 100%;
padding: 15px 20px 5px;
box-sizing: border-box;
}
.options-container .row {
padding: 0;
border: 0;
}
.options-container .container > .row:first-child {
padding-bottom: 18px;
color: #6b7280;
font-size: 13px;
line-height: 1.55;
border-bottom: 1px solid #eef0f3;
}
.options-container .container > .row:first-child > span {
display: block;
}
.options-container .container > .row:first-child hr,
.options-container hr.btn-set {
margin: 16px 0 14px;
border: 0 !important;
border-top: 1px solid #eef0f3 !important;
}
.options-container .row.title {
position: relative;
margin: 0;
padding: 16px 22px 13px 0;
color: #374151;
font-size: 13px;
font-weight: 700;
line-height: 1.3;
cursor: pointer;
background: transparent;
border-bottom: 1px solid #eef0f3;
}
.options-container .row.title:hover {
color: #2563eb;
}
.options-container .row.title::after {
content: "";
position: absolute;
top: 50%;
right: 2px;
width: 7px;
height: 7px;
border-right: 1.5px solid #6b7280;
border-bottom: 1.5px solid #6b7280;
transform: translateY(-65%) rotate(45deg);
}
.options-container .row.title + .row {
padding: 16px 0 18px;
border-bottom: 1px solid #eef0f3;
}
.hidden {
display: none !important;
}
.group {
padding-bottom: 14px;
}
.group:last-child {
padding-bottom: 0;
}
.options-container label {
display: block;
min-width: 0;
margin: 0 0 7px;
color: #374151;
font-size: 13px;
font-weight: 600;
line-height: 1.35;
}
.options-container input:not([type="checkbox"]):not([type="button"]),
.options-container select {
display: block;
width: 100%;
min-height: 34px;
margin: 0;
padding: 0 10px;
box-sizing: border-box;
color: #111827;
font: inherit;
background: #ffffff;
border: 1px solid #d8dde5;
border-radius: 6px;
outline: none;
transition: border-color .15s ease, box-shadow .15s ease;
}
.options-container input:not([type="checkbox"]):not([type="button"]):focus,
.options-container select:focus {
border-color: #2563eb;
box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.options-container input[type="checkbox"] {
display: inline-block;
width: 16px;
height: 16px;
margin: 0 8px 0 0;
padding: 0;
vertical-align: -3px;
accent-color: #2563eb;
}
.options-container button,
.options-container input[type="button"] {
min-height: 34px;
padding: 0 14px;
box-sizing: border-box;
color: #1f4f82;
font: inherit;
font-weight: 600;
cursor: pointer;
background: #fff;
border: 1px solid #9bb2cf;
border-radius: 4px;
transition: background-color .15s ease, border-color .15s ease;
}
.options-container button:hover,
.options-container input[type="button"]:hover {
background: #edf5ff;
border-color: #6f98c8;
}
.waterMark-btn {
width: auto;
min-width: 76px;
margin-right: 8px;
}
.custom-list-pane {
min-height: 92px;
padding: 8px 10px;
}
.options-container div.btn-set {
display: flex;
margin-top: 16px;
}
.options-container div.btn-set input[type="button"] {
width: 100%;
}
.options-container hr.btn-set {
margin: 18px 0 0;
}
#btnPrint {
margin-bottom: 0 !important;
}
@media (max-width: 760px) {
.sample-tutorial {
flex-direction: column;
}
.sample-spreadsheets {
min-height: 55%;
}
.options-container {
flex: 0 0 auto;
width: 100%;
height: 45%;
border-top: 1px solid #e5e7eb;
border-left: 0;
}
}