JAva操作Excelビッグデータ量ソリューションのエクスポート


Excelのエクスポート時にメモリオーバーフローが発生した場合、多くの解決策を見たことがあります.問題があれば、以下の解決策を提供します.
このプロジェクトはB/Sアーキテクチャを使用しており、POI、JXLはexcelのビッグデータ量をエクスポートすると大量のオブジェクトが発生し、最終的にメモリオーバーフローを引き起こすためです.実はExcelはhtmlファイルとして保存することができて、htmlに保存した後のファイルの内容は以下の通りです:

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 11">
……    ……
<body link=blue vlink=purple>
<table x:str border=0 cellpadding=0 cellspacing=0 width=620 style='border-collapse:
 collapse;table-layout:fixed;width:466pt'>
 <col width=129 style='mso-width-source:userset;mso-width-alt:4128;width:97pt'>
 <col class=xl25 width=72 span=2 style='width:54pt'>
 <col class=xl25 width=63 style='mso-width-source:userset;mso-width-alt:2016;
 width:47pt'>
 <col class=xl25 width=118 style='mso-width-source:userset;mso-width-alt:3776;
 width:89pt'>
 <col width=166 style='mso-width-source:userset;mso-width-alt:5312;width:125pt'>
 <tr height=19 style='height:14.25pt'>
  <td height=19 class=xl24 width=129 style='height:14.25pt;width:97pt'>  1</td>
  <td class=xl24 width=72 style='width:54pt'>  2</td>
  <td class=xl24 width=72 style='width:54pt'>  3</td>
  <td class=xl24 width=63 style='width:47pt'>  4</td>
  <td class=xl24 width=118 style='width:89pt'>  5</td>
  <td width=166 style='width:125pt'></td>
 </tr>
……  ……
 <![if supportMisalignedColumns]>
 <tr height=0 style='display:none'>
  <td width=129 style='width:97pt'></td>
  <td width=72 style='width:54pt'></td>
  <td width=72 style='width:54pt'></td>
  <td width=63 style='width:47pt'></td>
  <td width=118 style='width:89pt'></td>
  <td width=166 style='width:125pt'></td>
 </tr>
 <![endif]>
</table>
</body>
</html>

これにより、データにより上記形式のHTMLテキスト情報を生成することができ、大量のオブジェクトの作成を避けることができ、このHTMLを直接アプリケーション/excelでブラウザに戻すと、Excelファイルは通常より少し大きくなり、フィルタを構成することでそのHTMLを圧縮することができ、以下のようにすることができる.
	
response.reset(); 
response.setContentType("application/zip;charset=GBK");
String s = "  -" + new java.sql.Date(System.currentTimeMillis()).toString().replaceAll("-","") + ".xls";
String filename = s + ".zip";
response.addHeader("Content-Disposition", "inline;filename=" + filename);

以上は、Excelビッグデータ量をエクスポートするソリューションにすぎません.皆さんご意見をどうぞ!ありがとう!