没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
转帖|使用教程|编辑:鲍佳佳|2021-02-22 13:05:54.817|阅读 234 次
概述:此示例显示如何自定义工作簿背景。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
SpreadJS是一款基于 HTML5 的纯前端表格控件,兼容 450 种以上的 Excel 公式,具备“高性能、跨平台、与 Excel 高度兼容”的产品特性 可为用户带来亲切、易用的使用体验,并满足 Web Excel组件开发、表格文档协同编辑、 数据填报、 类Excel报表设计等业务场景,可极大降低企业研发成本和项目交付风险。
此示例显示如何自定义工作簿背景。
你可以设置 backColor 或者 backgroundImage 选项为每一个表单设置背景色或者背景图片。如果你同时设置背景色和背景图片, 那么背景图片将会优先显示。
var spread = GC.Spread.Sheets.findControl(document.getElementById('ss')); // set the worksheet's backcolor spread.options.backColor = 'red'; // and set the surrounding area spread.options.grayAreaBackColor = 'gray';
或者,您可以使用workbook的** backgroundImage **选项为工作表设置背景图像。请注意,设置背景图像会覆盖所有设置的背景颜色,因此必须将其删除才能使背景颜色生效。
var spread = GC.Spread.Sheets.findControl(document.getElementById('ss')); // Set a background image for the sheets spread.options.backgroundImage = 'images/backImage.png';
SpreadJS 提供控制图片布局方式的能力, 你可以设置 backgroundImageLayout 选项来完成此目标。图片布局包含以下几种类型:
spread.options.backgroundImageLayout = GC.Spread.Sheets.ImageLayout.stretch; //spread.options.backgroundImageLayout = GC.Spread.Sheets.ImageLayout.center; //spread.options.backgroundImageLayout = GC.Spread.Sheets.ImageLayout.zoom; //spread.options.backgroundImageLayout = GC.Spread.Sheets.ImageLayout.none;
你也可以设置 grayAreaBackColor 选项来设置表单灰色区域的背景色。
spread.options.grayAreaBackColor = 'gray';
app.js:
window.onload = function() { var spread = new GC.Spread.Sheets.Workbook(_getElementById('ss'), { sheetCount: 1 }); initSpread(spread); }; function initSpread(spread) { var spreadNS = GC.Spread.Sheets; var sheet = spread.getSheet(0); var pictureUrl = ''; spread.suspendPaint(); sheet.setRowCount(15); sheet.setColumnCount(20); spread.options.backColor = 'white'; spread.options.grayAreaBackColor = 'gray'; spread.options.backgroundImageLayout = spreadNS.ImageLayout.stretch; spread.options.backgroundImage = '$DEMOROOT$/spread/source/images/backImage.png'; spread.resumePaint(); _getElementById('layout').addEventListener('change',function() { var layout = parseInt(document.getElementById('layout').value); spread.options.backgroundImageLayout = layout; }); _getElementById('setGrayAreaBackColor').addEventListener('click', function() { var color = document.getElementById('grayAreaBackColor').value; spread.options.grayAreaBackColor = color; }); _getElementById('setSpreadBackColor').addEventListener('click', function() { var color = document.getElementById('spreadBackColor').value; spread.options.backColor = color; }); _getElementById('file_input').addEventListener('change', function() { var file = this.files[0]; if (!/image\/\w+/.test(file.type)) { alert('The file muse be image!'); return false; } var reader = new FileReader(); reader.readAsDataURL(file); reader.onload = function(e) { pictureUrl = this.result; }; }); _getElementById('setSpreadBackgroundImage').addEventListener('click', function() { spread.options.backgroundImage = pictureUrl; }); _getElementById('delSpreadBackgroundImage').addEventListener('click', function() { spread.options.backgroundImage = ''; }); } function _getElementById(id){ return document.getElementById(id); }
index.html:
<!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/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity/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="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> <div class="options-container"> <div class="option-row"> <label >Enter a color name to set the color of the workbook gray area.</label> </div> <div class="option-row"> <input type="text" id="grayAreaBackColor"/> <input type="button" id="setGrayAreaBackColor" value="Set Gray Area BackColor"/> </div> <div class="option-row"> <label >Enter a color name to set the workbook background color.</label> <label class="note">Note: remove background image at the bottom to see this change.</label> </div> <div class="option-row"> <input type="text" id="spreadBackColor"/> <input type="button" id="setSpreadBackColor" value="Set Workbook BackColor"/> </div> <div class="option-row"> <label >Image:</label> <input type="file" name="image" id="file_input" /> </div> <div class="option-row"> <label >Workbook Background Image Layout:</label> <select id="layout" > <option value="0" selected="selected">Stretch</option> <option value="1">Center</option> <option value="2">Zoom</option> <option value="3">None</option> </select> </div> <div class="option-row"> <input type="button" id="setSpreadBackgroundImage" value="Set" class="narrow-button" /> <input type="button" id="delSpreadBackgroundImage" value="Del Background Image" /> </div> </div> </div> </body> </html>
style.css:
input[type="button"] { width: 180px; } input[type="text"] { padding: 4px; margin-top: 4px; width: 100%; box-sizing: border-box; } label { display: inline-block; margin-bottom: 6px; } .note{ margin-top: 0px; } .colorLabel { background-color: lavender; } .wide-label { width: 260px; } input.narrow-button, .narrow-label { width: 74px; } .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: calc(100% - 300px); height: 100%; overflow: hidden; float: left; } .options-container { float: right; width: 300px; padding: 12px; height: 100%; box-sizing: border-box; background: #fbfbfb; overflow: auto; } .option-row:nth-child(1){ padding-bottom: 0px; } .option-row:nth-child(2){ margin-top: 0px; padding-top: 0px; } .option-row:nth-child(3){ padding-bottom: 0px; } .option-row:nth-child(4){ margin-top: 0px; padding-top: 0px; } .option-row { font-size: 14px; padding: 5px; margin-top: 10px; } input { padding: 4px 6px; } input[type=button] { margin-top: 6px; display: block; } hr { border-color: #fff; opacity: .2; margin-top: 20px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }
本文转载自:葡萄城
赶快下载体验吧!现推出限时活动,SpreadJS正版授权低至3490元!欢迎咨询慧都在线客服了解详情!
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@wqylolg.cn
文章转载自:可视化项目时间线对于有效规划和跟踪至关重要。在本篇博文中,您将学习如何使用 C# 在 Excel 中创建甘特图。只需几行代码,即可自动生成动态、美观的甘特图。
本文将为大家介绍DevExpress XAF如何将.NET Aspire集成到Blazor项目中,欢迎下载最新版组件体验!
在线协同文档编辑器ONLYOFFICE现已支持阿里通义千问( Qwen),带来先进的 AI 功能,实现更智能的文档编辑。本指南将向您展示如何将 Qwen 连接到 ONLYOFFICE,并充分利用其功能。
需要从 PDF 文档中删除特定页面?本快速指南将向您展示如何仅用几行代码删除不需要的页面。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢