Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

java - Apache POI autoSizeColumn() is not working

I've created an excel sheet using apache poi library and tried so much to change column width with respect to the content length by using autoSizeColumn() method, but no luck. I've used poi 2.5.1 and jdk 1.6. This is my code segment.

for (int columnIndex = 0; columnIndex < 8; columnIndex++) {
 sheet.autoSizeColumn(columnIndex);
}

I've used this code segment after inserting data to the excel sheet. The error message said that "cannot find symbol"

Any help would be appreciated.

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your version of Apache POI (2.5.1) is quite old (released 2004-02-29) and for that version, the Sheet interface doesn't have the autoSizeColumn method. For most open source projects, the documentation on the web is usually for the current stable release, which for POI is currently 3.9 (released 2012-12-03).

You can get source & documentation for your version of POI, but consider upgrading your version of POI - the latest version works with Java 1.6.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...