Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JSP (http://www.go4expert.com/forums/jsp/)
-   -   Problem while opening Excel files (http://www.go4expert.com/forums/excel-files-t9727/)

priyapratheep 3Apr2008 10:06

Problem while opening Excel files
 
Hi friends

when i try to download data from MySQL to excel sheet I am getting error of

This file is not in a recognizable format.


. If you know the file is from another program which is incompatible with Microsoft Office Excel,click Cancel then open this file in its original application.If you want to open the file later in Microsoft Office Excel,save it in a format that is compatible,such as text format.

etc

Code is
Code:

Class.forName("org.gjt.mm.mysql.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://203.116.109.81/mydb","chocku","chocku");
Statement st = conn.createStatement();

StringBuffer sb = new StringBuffer();
sb.append("SAP#" + "\t");
sb.append("x-plant status" + "\t");
sb.append("Total Amount" +"\t");
sb.append(">90 days" + "\t");

sb.append("\n");

try
{
String query="select * from temp_Xplant";
ResultSet rs = st.executeQuery(query);
while(rs.next()){
sb.append(rs.getString("sapNo") + "\t");
sb.append(rs.getString("status")+ "\t");
sb.append(rs.getString("amt") + "\t");
sb.append(rs.getString("days") + "\t");
sb.append("\n");

}

conn.close();
st.close();

}

catch (Exception e)
{
out.println("error");
conn.close();
st.close();
}


response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=\"test.XLS\"");

I can open them after clicking OK, but before that it is showing the above error message

thank you


All times are GMT +5.5. The time now is 12:37.