Handsontable - 文本在数字单元格上对齐
Handsontable - text align on numeric cells
我正在使用 handsontable 在 ASP.NET MVC Excel 类应用程序中编辑数字数据。
我通过以下代码设置单元格格式:
numeral.language('ru', {
delimiters: {
thousands: ' ',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
return number === 1 ? 'er' : 'ème';
},
currency: {
symbol: '€'
}
});
var container = document.getElementById('hot');
var workflowActionType = '@ViewBag.WorkflowActionType';
var hot = new Handsontable(container,
{
data: data,
maxRows: 32,
colWidths: [500, 60, 100, 100, 100, 100],
cells: function (row, col, prop) {
var cellProperties = {};
cellProperties.type = "numeric";
cellProperties.format = '0.00';
cellProperties.language = 'ru';
if (row === 0) {
cellProperties.renderer = headerRowRenderer;
cellProperties.readOnly = true;
}
if (col === 0 && (row !== 0 || row !== 1)) {
cellProperties.readOnly = true;
}
if (row === 1) {
cellProperties.renderer = numberRowRenderer;
cellProperties.readOnly = true;
}
if (col === 1 && row !== 0 && row !== 1) {
cellProperties.renderer = rowCodeRenderer;
cellProperties.readOnly = true;
}
if ((col === 2 || col === 3 || col === 4 || col === 5) &&
(row === 0 || row === 1)) {
cellProperties.readOnly = true;
}
return cellProperties;
}
});
此行设置的数字格式:
cellProperties.type = "numeric";
cellProperties.format = '0.00';
cellProperties.language = 'ru';
之后,在本地开发环境(由 Visual Studio 运行的 IIS Express)中,所有数字都正确对齐。但是在生产服务器上——所有的数字都是左对齐的。我做错了什么?
问题已解决。
开发和生产服务器上不同区域设置导致的不同数字渲染。在开发机器上,DB 使用点“.”作为小数点分隔符,在生产服务器 DB 上使用逗号“,”作为小数点分隔符。通过设置正确的语言环境重新创建生产数据库解决。
我正在使用 handsontable 在 ASP.NET MVC Excel 类应用程序中编辑数字数据。 我通过以下代码设置单元格格式:
numeral.language('ru', {
delimiters: {
thousands: ' ',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
return number === 1 ? 'er' : 'ème';
},
currency: {
symbol: '€'
}
});
var container = document.getElementById('hot');
var workflowActionType = '@ViewBag.WorkflowActionType';
var hot = new Handsontable(container,
{
data: data,
maxRows: 32,
colWidths: [500, 60, 100, 100, 100, 100],
cells: function (row, col, prop) {
var cellProperties = {};
cellProperties.type = "numeric";
cellProperties.format = '0.00';
cellProperties.language = 'ru';
if (row === 0) {
cellProperties.renderer = headerRowRenderer;
cellProperties.readOnly = true;
}
if (col === 0 && (row !== 0 || row !== 1)) {
cellProperties.readOnly = true;
}
if (row === 1) {
cellProperties.renderer = numberRowRenderer;
cellProperties.readOnly = true;
}
if (col === 1 && row !== 0 && row !== 1) {
cellProperties.renderer = rowCodeRenderer;
cellProperties.readOnly = true;
}
if ((col === 2 || col === 3 || col === 4 || col === 5) &&
(row === 0 || row === 1)) {
cellProperties.readOnly = true;
}
return cellProperties;
}
});
此行设置的数字格式:
cellProperties.type = "numeric";
cellProperties.format = '0.00';
cellProperties.language = 'ru';
之后,在本地开发环境(由 Visual Studio 运行的 IIS Express)中,所有数字都正确对齐。但是在生产服务器上——所有的数字都是左对齐的。我做错了什么?
问题已解决。
开发和生产服务器上不同区域设置导致的不同数字渲染。在开发机器上,DB 使用点“.”作为小数点分隔符,在生产服务器 DB 上使用逗号“,”作为小数点分隔符。通过设置正确的语言环境重新创建生产数据库解决。