excel 本身没有表头的概念,所以导出后是没有的,
您可以在导出前,给sheet 插入行设置复制行头
[code] var tempSpread = new GC.Spread.Sheets.Workbook();
tempSpread.fromJSON(json);
var hearderStyle = new GC.Spread.Sheets.Style();
hearderStyle.borderLeft =new GC.Spread.Sheets.LineBorder("black",GC.Spread.Sheets.LineStyle.medium);
hearderStyle.borderTop = new GC.Spread.Sheets.LineBorder("black",GC.Spread.Sheets.LineStyle.medium);
hearderStyle.borderRight = new GC.Spread.Sheets.LineBorder("black",GC.Spread.Sheets.LineStyle.medium);
hearderStyle.borderBottom = new GC.Spread.Sheets.LineBorder("black",GC.Spread.Sheets.LineStyle.medium);
for(var sheetPro in tempSpread.sheets){
var sheet = tempSpread.sheets[sheetPro]
if(!(sheet instanceof GC.Spread.Sheets.Worksheet)){
continue;
}
var headerRowCount = sheet.getRowCount(GC.Spread.Sheets.SheetArea.colHeader)
var colCount = sheet.getColumnCount();
//判断是否需要导出列头
if(headerRowCount > 1 || sheet.getText(0, 0, GC.Spread.Sheets.SheetArea.colHeader) !== "A"){
sheet.addRows(0, headerRowCount);
for(var row = 0; row < headerRowCount; row++){
sheet.setStyle(row, -1, hearderStyle);
for(var col = 0; col < sheet.getColumnCount(); col++){
sheet.setValue(row, col, sheet.getText(row, col, GC.Spread.Sheets.SheetArea.colHeader));
var span = sheet.getSpan(row, col, GC.Spread.Sheets.SheetArea.colHeader)
if(span && span.row === row && span.col ===col && (span.rowCount > 1 || span.colCount > 1) && span.rowCount <= headerRowCount - span.row && span.colCount <= colCount - span.col){
sheet.addSpan(span.row, span.col, span.rowCount, span.colCount)
}
}
}
}
}
var newJSON = tempSpread.toJSON(options);
|