Javascript 可手持-数字单元格上的文本对齐
我在ASP.NET MVC Excel类应用程序中使用handsontable编辑数字数据。 我通过以下代码设置单元格格式:Javascript 可手持-数字单元格上的文本对齐,javascript,asp.net,handsontable,Javascript,Asp.net,Handsontable,我在ASP.NET MVC Excel类应用程序中使用handsontable编辑数字数据。 我通过以下代码设置单元格格式: numeral.language('ru', { delimiters: { thousands: ' ', decimal: ',' }, abbreviations: { thousand: 'k', million: 'm', billion: 'b',
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';
之后,在本地开发环境(VisualStudio运行的IIS Express)上,所有数字都对齐。但在生产服务器上,所有数字都是左对齐的。我做错了什么?问题已解决
由开发和生产服务器上的不同区域设置导致的不同数字呈现。在开发机器上,DB使用点“.”作为十进制分隔符,在生产服务器上,DB使用逗号“.”作为十进制分隔符。通过设置正确的区域设置重新创建生产数据库来解决此问题