Regarding Convert DB table into XL

View: New views
2 Messages — Rating Filter:   Alert me  

Regarding Convert DB table into XL

by Edi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I have mssql employee table with 10 fields with data. I want to import all the db data into xls using poi program.

Is it possible? if yes, please advise.

thanks and regards,
edi

Re: Regarding Convert DB table into XL

by Felix Kalka :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Edi,
im myself a newbie with POI but i just looked at this page:
http://poi.apache.org/hssf/quick-guide.html#CreateCells
;)
so i think u have to write something like this:

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");

int i=0;
while (get new row from mssql)
{
    HSSFRow row = sheet.createRow((short)i);
    i++;
    for (int n=0; n<11; n++)
    {
       HSSFCell cell = row.createCell((short)n);
       cell.setCellValue(value of mssql field n);
       }
}

// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();

greetings,
felix



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...

LightInTheBox - Buy quality products at wholesale price