Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Row column settings when opened through JAVA.

Status
Not open for further replies.

brahman

Programmer
Apr 17, 2003
21
0
0
IN
Dear Friends,
I am opening a Excel file containing my recordsets using java , now how can I set the cell size to autofit the contents from the table.

The looks are coming ugly so how to make those changes.

Please guide me.

Bye for now
amit
 
I dont know how you access the Excel file, but I'd suggest that you use the POI API.


The extensive documentation will describe how to access the cell properties.

Br
jza
 
the result set is opened fetched from an SQL server recordset and than take in to a excel sheet but the formatting is not proper when i get the file.

how can i set the properties directly in the JAVA code so that the resultant file contains it.

bye for now
amit
 
is there any way i can set the column width according to the record in the cell to fit the content.

Is there any setWidth method for the column.
 
I am using this code to drive the excel sheet from my JAVA code. Use the worksheet as an object by extending it to the excel8.olb file. Use the following code in your try catch scenario.

using namespace Excel;
_ApplicationPtr pXL;
pXL.CreateInstance(L"Excel.Application.8");
WorkbooksPtr pBooks = pXL.Workbooks;
_WorksheetPtr pSheet = pXL.ActiveSheet;

Now if I want to set the column width of colum D to 10 pixel then use the following code.

pSheet.Range["D3"].PutColumnWidth= 4.0;

This will work and solve all your problems.
 
-->times16formatNormal.setAlignment(jxl.format.Alignment.LEFT);


-->Label label1 = new Label(0,4, "Organisation Name ",times16format);


-->sheet.addCell(label1);

how to set the column width for the column i know with this code.
I am using JXL api to generate the excel sheet.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top