Commit 3b1f768f authored by Alexander.Trofimov's avatar Alexander.Trofimov

charCountToModelColWidth move to model

fix set width in api builder
parent b7acb4d8
...@@ -1997,6 +1997,9 @@ function Workbook(eventsHandlers, oApi){ ...@@ -1997,6 +1997,9 @@ function Workbook(eventsHandlers, oApi){
this.openErrors = []; this.openErrors = [];
this.lockCounter = 0; this.lockCounter = 0;
this.maxDigitWidth = 0;
this.paddingPlusBorder = 0;
} }
Workbook.prototype.init=function(bNoBuildDep){ Workbook.prototype.init=function(bNoBuildDep){
if(this.nActive < 0) if(this.nActive < 0)
...@@ -3237,6 +3240,17 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){ ...@@ -3237,6 +3240,17 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){
} }
} }
}; };
/**
* Вычисляет ширину столбца для заданного количества символов
* @param {Number} count Количество символов
* @returns {Number} Ширина столбца в символах
*/
Workbook.prototype.charCountToModelColWidth = function (count) {
if (count <= 0) {
return 0;
}
return Asc.floor((count * this.maxDigitWidth + this.paddingPlusBorder) / this.maxDigitWidth * 256) / 256;
};
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
/** /**
* @constructor * @constructor
...@@ -4259,6 +4273,9 @@ Woorksheet.prototype.getDefaultFontName=function(){ ...@@ -4259,6 +4273,9 @@ Woorksheet.prototype.getDefaultFontName=function(){
Woorksheet.prototype.getDefaultFontSize=function(){ Woorksheet.prototype.getDefaultFontSize=function(){
return this.workbook.getDefaultSize(); return this.workbook.getDefaultSize();
}; };
Woorksheet.prototype.charCountToModelColWidth = function (count) {
return this.workbook.charCountToModelColWidth(count);
};
Woorksheet.prototype.getColWidth=function(index){ Woorksheet.prototype.getColWidth=function(index){
//index 0 based //index 0 based
//Результат в пунктах //Результат в пунктах
...@@ -4272,8 +4289,10 @@ Woorksheet.prototype.getColWidth=function(index){ ...@@ -4272,8 +4289,10 @@ Woorksheet.prototype.getColWidth=function(index){
return dResult; return dResult;
}; };
Woorksheet.prototype.setColWidth=function(width, start, stop){ Woorksheet.prototype.setColWidth=function(width, start, stop){
width = this.charCountToModelColWidth(width);
if(0 == width) if(0 == width)
return this.setColHidden(true, start, stop); return this.setColHidden(true, start, stop);
//start, stop 0 based //start, stop 0 based
if(null == start) if(null == start)
return; return;
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment