2017-07-11 14 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などのライブラリを使用する必要があります。

関連する問題