import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ooxml.POIXMLProperties;
import java.io.File;
public class ExcelPropertiesExample {
public static void main(String[] args) {
try {
// Excelファイルの読み込み
OPCPackage opcPackage = OPCPackage.open(new File("あなたのファイルパス.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(opcPackage);
// プロパティの取得
POIXMLProperties props = workbook.getProperties();
POIXMLProperties.CoreProperties coreProps = props.getCoreProperties();
String title = coreProps.getTitle();
String subject = coreProps.getSubject();
String author = coreProps.getCreator();
// プロパティの表示
System.out.println("タイトル: " + title);
System.out.println("サブジェクト: " + subject);
System.out.println("作者: " + author);
workbook.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}