您好:
可以通过celltype中的getAutoFitWidth方法来获取,参考代码如下:
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
- var sheet = spread.getActiveSheet();
- sheet.setValue(0,0,"TEST TEXT LENGTH");
- var instance = new GC.Spread.Sheets.CellTypes.Text();
- var returnValue = instance.getAutoFitWidth(
- sheet.getValue(0,0), sheet.getText(0,0), sheet.getActualStyle(0,0), sheet.zoom(), {
- "sheet":sheet,
- "row":0,
- "col":0,
- "sheetArea":GC.Spread.Sheets.SheetArea.viewport
- }
- );
- alert(returnValue);
复制代码 |