Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Write into an XL sheet from java prg

 
varsha rao
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
i have to design a Gui with some menus, each menu has an associated query. When user clicks on a menu , the associated query gets executed and the results are to be written in a XL sheet. How do i do this, i have to use JSP for the GUI . Can some one please help me out with this.
Its really urgent.
regards
Varsha
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several options for writing to an Excel spreadsheet documented in our AccessingFileFormats FAQ
 
varsha rao
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for telling me the required links, i tried out the following prg, but im getting UnSupportedClassVersionError exception while running the prg. Please tell me why this exception is coming and how to rectify it.

following is the prg

import java.io.*;
import org.apache.poi.hssf.usermodel.*;

public class XLTrial
{
public static void main(String args[])throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");

// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow((short)0);
// Create a cell and put a value in it.
HSSFCell cell = row.createCell((short)0);
cell.setCellValue(1);

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


When i run the prg this is the exception im getting

Exception in thread "main" java.lang.UnsupportedClassVersionError: XLTrial (Unsu
pported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the code is compiled using one java version (may be JDK5) and being run using another jdk version (may be JDK1.4)
 
varsha rao
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No i have only jdk1.5 installed on my system,i don have any other versions on java. Still this is happening , i don know why
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15715
73
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really, the unsupported class version error can only mean that you are trying to run a Java class compiled with Java 5 on an older version of Java.

Check your system again. Do you have Oracle software installed? Oracle has the nasty habit of installing a Java 1.3 JRE on your system and putting it into the PATH.

What does "java -version" tell you?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!