<!DOCTYPE html>
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js" data-semver="2.1.1" data-require="jquery@*"></script>
<link href="http://cdn.wijmo.com/spreadjs/jquery.wijmo.wijspread.3.20143.14.css" rel="stylesheet" data-semver="3.20143.14" data-require="SpreadJS@*" />
<script src="http://cdn.wijmo.com/spreadjs/jquery.wijmo.wijspread.all.3.20143.14.min.js" data-semver="3.20143.14" data-require="SpreadJS@*"></script>
<script src="test.js"></script>
<script src="script.js"></script>
<link href="style.css" rel="stylesheet" />
</head>
<body>
<h1>Hello SpreadJS!</h1>
<div style="width: 800px; height: 500px; border: 1px solid gray" id="ss"></div>
</body>
</html>
function DoubleUnderLineCellType() {}
DoubleUnderLineCellType.prototype = new $.wijmo.wijspread.TextCellType();
DoubleUnderLineCellType.prototype._renderTextDecoration = function(ctx, textDecoration, x, y, textLength, fontSize, offset) {
ctx.strokeStyle = ctx.fillStyle;
if (ctx.textAlign === "center") {
x = x - textLength / 2
} else if (ctx.textAlign === "right") {
x = x - textLength
}
ctx.beginPath();
var vposY = Math.ceil(y + offset - 1) - 0.5;
ctx.moveTo(x, vposY);
ctx.lineTo(x + textLength, vposY);
ctx.moveTo(x, vposY + 2);
ctx.lineTo(x + textLength, vposY + 2);
ctx.stroke()
}
function CurrencyCellType() {}
CurrencyCellType.prototype = new $.wijmo.wijspread.TextCellType();
CurrencyCellType.prototype.paint = function(ctx, value, x, y, w, h, style, options) {
$.wijmo.wijspread.TextCellType.prototype.paint.apply(this, arguments);
value = "$";
$.wijmo.wijspread.TextCellType.prototype.paint.apply(this, arguments);
if (!style.textDecoration) return;
ctx.save();
var fillStyle = style.foreColor;
ctx.fillStyle = fillStyle;
ctx.rect(x, y, w, h);
ctx.clip();
ctx.beginPath();
x += 2;
if (style.vAlign === 0) {
y += options.lineHeight + 1;
} else if (style.vAlign === 1) {
y += (h + options.lineHeight) / 2-1;
} else if (style.vAlign === 2) {
y += h-3;
}
ctx.strokeStyle = ctx.fillStyle;
var vposY = Math.ceil(y) - 0.5;
ctx.moveTo(x, vposY);
ctx.lineTo(x + w - 4, vposY);
ctx.moveTo(x, vposY + 2);
ctx.lineTo(x + w - 4, vposY + 2);
ctx.stroke();
ctx.restore();
}
function CurrencyCellType2() {}
CurrencyCellType2.prototype = new DoubleUnderLineCellType();
CurrencyCellType2.prototype.paint = function(ctx, value, x, y, w, h, style, options) {
$.wijmo.wijspread.TextCellType.prototype.paint.apply(this, arguments);
ctx.font = style.font;
var spaceCharWidth = ctx.measureText(" ").width;
var count = Math.ceil(w / spaceCharWidth);
value = "$" + Array(count - 3).join(" ");
$.wijmo.wijspread.TextCellType.prototype.paint.apply(this, arguments);
}
$(document).ready(function() {
$("#ss").wijspread();
var spread = $("#ss").wijspread("spread");
var sheet = spread.getActiveSheet();
sheet.getRows(0, 8).height(30);
sheet.getCell(0, 0).text("This").cellType(new DoubleUnderLineCellType()).textDecoration("DoubleLine");
sheet.getCell(1, 0).foreColor("red").value(123456).vAlign(2).cellType(new DoubleUnderLineCellType()).textDecoration("DoubleLine");
sheet.getCell(2, 0).font("20px arial").text("This is").cellType(new DoubleUnderLineCellType()).textDecoration("DoubleLine");
sheet.getCell(3, 0).font("italic bold 15px/30px Georgia").value(123).cellType(new CurrencyCellType());
sheet.getCell(4, 0).font("20px arial").value(456).cellType(new CurrencyCellType()).textDecoration("DoubleLine");
sheet.getCell(5, 0).foreColor("red").vAlign(2).value(789).cellType(new CurrencyCellType()).textDecoration("DoubleLine");
sheet.getCell(6, 0).font("italic bold 15px/30px Georgia").value(123).cellType(new CurrencyCellType2());
sheet.getCell(7, 0).font("20px arial").value(456).cellType(new CurrencyCellType2()).textDecoration("DoubleLine");
sheet.getCell(8, 0).foreColor("red").vAlign(2).value(789).cellType(new CurrencyCellType2()).textDecoration("DoubleLine");
});
/* Styles go here */
This is a sample shows how to add double underline to cell text,
and also shows how to display the currency synbol (left align) separat from the value number (right align).