Ken,
There may something else to it since the following code works
fine for me:
<code>
import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class TestColWidth {
private static final String PATH = "c:/temp/testwidth.xls";
public static void main(String[] args) throws Exception {
HSSFWorkbook w = new HSSFWorkbook();
HSSFSheet s = w.createSheet();
s.setColumnWidth((short) 2, (short) (15*256)); // COL C
s.setColumnWidth((short) 1, (short) (40*256)); // COL B
s.setColumnWidth((short) 0, (short) (80*256)); // COL A
w.write(new FileOutputStream(PATH));
}
}
</code>
HTH,
~ amol
> -----Original Message-----
> From: Kenneth Litwak [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 20, 2005 3:20 PM
> To: [email protected]
> Subject: Can't affect column width
>
>
> I'm having trouble getting my spreadsheet columns to show the size
> settings I have given to columns. I have
>
> gwrWS.setColumnWidth((short) 1,
> (short) ( 40 * 256 )); // Student ID
> gwrWS.setColumnWidth((short) 2,
> (short) ( 45 * 256 )); // Timestamp
> gwrWS.setColumnWidth((short) 3,
> (short) ( 10 * 256 )); // Term
>
> No matter what I do to these numbers, the column width when I open the
> spreadsheet in Excel look the same .Column 3 is overly wide, while
> column 1 is too narrow. Column 1 needs to hold a 9-digit
> number, but I
> only ever get six visible digits. I can manually stretch the column to
> see more, but I want the column to display correctly without
> any manual
> effort. Thanks.
>
> Ken
>
>
> Kenneth D. Litwak
> Software Engineer III
> IMT
> Azusa Pacific University
> 901 E. Alosta
> Azusa, CA 91702
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/