POIを使用してエクセルファイルを出力する処理がある。 48列で最大10000行のデータを出力する仕様だが、10000行を出力しようとしたところ、OutOfMemoryエラーが発生した。 そんな場合の対応方法をメモ。 #そもそもJavaでそんなに大量のデータをエクセルで扱うなというのは言わないで頂きたい。。 問題の実装 問題発生したソースのイメージは以下の通り。 File file = new File(tempPath); //一時ファイルパス 事前にファイル作成済みこれをテンプレートとする XSSFWorkbook workbook = (XSSFWorkbook) WorkbookFactory.create(file); XSSFSheet sheet = workbook.getSheetAt(0); XSSFRow baseRow = sheet.getRow(sheet.ge
はじめに 事前に以下のライブラリを用意します。 Apache POI https://poi.apache.org/download.html ※"poi-bin-3.16-20170419.tar.gz"のリンクからダウンロード 今回のサンプルは以下のjarがあれば動作します。 poi-3.16.jar poi-ooxml-3.16.jar poi-ooxml-schemas-3.16.jar xmlbeans-2.6.0.jar commons-collections4-4.1.jar 実装例 今回のサンプルでは以下の機能を確認します。 複数のシートを作成する ウィンドウ枠の固定を設定する オートフィルタを設定する 列幅を自動調整する セルに文字列を表示する セルに改行入りの文字列を表示する セルに整数を表示する セルに小数を表示する セルに円を表示する セルにパーセントを表示する セ
/** * ワークブックの作成 */ // HSSF HSSFWorkbook workbook1 = new HSSFWorkbook(); // XSSF XSSFWorkbook workbook2 = new XSSFWorkbook(); // Workbook (HSSFWorkbookクラス及びXSSFWorkbookクラスの共通インタフェース) Workbook workbook3 = new HSSFWorkbook(); Workbook workbook4 = new XSSFWorkbook(); /** * シートの作成、シートの指定 */ // HSSF HSSFSheet sheet1 = workbook1.createSheet(); // シート名による指定 sheet1 = workbook1.getSheet("シート1"); // インデックスによ
Apache POI(以前はJakarta POIと呼ばれていました)はJavaアプリケーションからExcelやWordなどのMicrosoft製品のフォーマットファイルを読み書きするためのAPIです。 今回は特にExcelのファイルを対象として試していきますが、Excelのファイルの読み書きではApache POIの中のHSSFとXSSFを使用します。HSSFはExcel2003までのファイルフォーマットに対応したもので、XSSFはExcel2007のOOXML(.xlsx)ファイルフォーマットに対応したものです。 Apache POI 3.6のダウンロード Apache POI 3.6のインストール クラスパスの設定
ダウンロード [/2015-11-11] サンプル API ワークブック [/2017-01-27] ワークシート [/2014-10-13] セル [/2020-09-12] セルスタイル [/2015-08-27] セル位置 [/2015-08-27] ダウンロード POIのライブラリー(jarファイル)を使うには、Gradleを使っていれば、build.gradleの依存関係にPOIを指定すればよい。 build.gradle: apply plugin: 'java' apply plugin: 'eclipse' repositories { mavenCentral() } dependencies { compile group: 'org.apache.poi', name : 'poi', version: '3.13' compile(group: 'org.apach
This page provides instructions on how to download and verify the Apache POI release artifacts. There are different versions available depending on how stable your code should be. The latest stable release is Apache POI 5.3.0 Archives of all prior releases Apache POI releases are available under the Apache License, Version 2.0. See the NOTICE file contained in each release artifact for applicable
はじめに この投稿は個人的なメモ書きです。 Apache-POIを利用してExcelファイルを読み取る時に、メソッドの使い方や気をつけることなどのtipsをまとめていこうと思います。 内容は随時更新していく予定です。 準備 POIのバージョンは投稿時の最新Release版の3.14を使っています。 今回はMavenを使うのでpom.xmlに下記を追加 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.14</version> </dependency>
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く