2017-07-11 131 views
0

我正在使用AngularJS生成Excel文件。使用AngularJS的Excel页面属性

页面样式格式工作正常,但我需要帮助来设置打印区域和方向景观的页面属性。

代码:

var mystyle = { 
     sheetid: 'Sheet1', 
     headers: false, 
     style: 'background:none', 
     columns: [{ 
      columnid: 'PRODUCT', 
      width: 140, 
      wraptext: true 
     }, 
     { 
      columnid: 'DESCRIPTION', 
      width: 400, 
      wraptext: true 
     }, { 
      columnid: 'QTY', 
      width: 40, 
      wraptext: true 
     }, 
     { 
      columnid: 'LIST_PRICE', 
      width: 80, 
      wraptext: true 
     }, 
      { 
       columnid: 'DISC_PRICE', 
       width: 80, 
       wraptext: true 
      }, 
      { 
       columnid: 'EXT_PRICE', 
       width: 80, 
       wraptext: true 
      }, 
      { 
       columnid: 'OPTIONS', 
       wraptext: true, 
       width: 500, 
      } 

     ], 
     row: { 
      style: function (sheet, row, rowidx) { 
       row.QTY = row.QTY != '' ? (Number(row.QTY)) : ''; 
       row.LIST_PRICE = row.LIST_PRICE != '' ?(parseFloat(row.LIST_PRICE)): ''; 
       row.DISC_PRICE = row.DISC_PRICE != '' ? row.DISC_PRICE == 'Total' ? row.DISC_PRICE : (parseFloat(row.DISC_PRICE)) : ''; 
       row.EXT_PRICE = row.EXT_PRICE != '' ? (parseFloat(row.EXT_PRICE)) : ''; 
       return 'font-weight:' + (row.QTY == '' ? 'bold' : 'none'); 
      } 
     }, 
     rows: { 
      7: { style: { Font: { Bold: 1 } } }, 
      1: { style: { Font: { Bold: 1 } } }, 
      2: { style: { Font: { Bold: 1 } } }, 
      3: { style: { Font: { Bold: 1 } } }, 
      7: { style: 'font-weight: bold;' } 
     }, 
     cells: { 
      1: { 
       1: { 
        style: 'font-weight: bold;font-size:15px;'//, 
        // value: function (value) { return value.substr(1, 5); } 
       } 
      }, 
      2: { 
       1: { 
        style: 'font-weight: bold;font-size:15px;'//, 
        // value: function (value) { return value.substr(1, 5); } 
       } 
      }, 
      3: { 
       1: { 
        style: 'font-weight: bold;font-size:15px;'//, 
        // value: function (value) { return value.substr(1, 5); } 
       } 
      }, 
      7: { 
       0: { 
        style: 'border-bottom: 5px solid black;' 
       }, 
       1: { 
        style: 'border-bottom: 5px solid black;' 
       }, 
       2: { 
        style: 'border-bottom: 5px solid black;text-align:right' 
       }, 
       3: { 
        style: 'border-bottom: 5px solid black;text-align:right;' 
       }, 
       4: { 
        style: 'border-bottom: 5px solid black;text-align:right;' 
       }, 
       5: { 
        style: 'border-bottom: 5px solid black;text-align:right;' 
       } 

      } 
     } 
    }; 
    var GetExcelData = SaveOrderService.ExportToExcel(quoteType, $scope.comments); 
    GetExcelData.then(function (data) { 
     $scope.items = []; 
     $scope.items = data.data; 
     alasql('SELECT * INTO XLS("'+$scope.excelfilename+'",?) FROM ?', [mystyle, $scope.items]); 
    }); 


}; 

回答

0

当您生成一个Excel文件,这样你实际上只生成HTML格式的飞行Excel的进口,而不是实际的Excel文件。因此,高级格式设置(如打印首选项,数据过滤器和Excel图表)将无法使用。

为了做你想做的事情,你必须在你的服务器上使用一个库,例如Apache POI