Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Urgent: Java to Microsoft Office.Need Help!!!

807605Sep 26 2007 — edited Sep 26 2007
Hello everybody, I'm an Instructor, I teach Microsoft Office applications to children
I'm trying to build a Java program that can open Microsoft office files (Word, Excel), as a step to an Online Microsoft office exams,
I want the program to check whether the student had solved a certain question that tells him to Embolden or Underline a certain text in Word, or a Cell in Excel.
I found a Program Called J-Integra i downloaded it and changed the classpath as it appears in the program documentation but still getting the following Error

*"C:\pure\ExcelExample.java:9: package com.linar.jintegra does not exist*
com.linar.jintegra.Log.logImmediately(3, "jintegra.log");"+

this is what I did to update the classpath:
C:\pure>set PATH=%PATH%;C:\Program Files\Java\jdk1.5.0_01\bin.;C:\Program Files\J-Integra\com\bin
C:\pure>set CLASSPATH=.;C:\Program Files\J-Integra\com\lib\jintegra.jar

and this is the code:
__________________
import excel.*;
import java.util.Date;

public class ExcelExample {

public static void main(java.lang.String[] args) {
try {
// Create a jintegra.log file in the same directory as this Java file
com.linar.jintegra.Log.logImmediately(3, "jintegra.log");

// Uncomment this line if ExcelExample.java remotely accesses Excel:
// com.linar.jintegra.AuthInfo.setDefault("NT DOMAIN", "NT USER", "NT PASSWORD");

// Uncomment this line if ExcelExample.java remotely accesses Excel
// Pass IP Address of remote machine to its constructor
// Application app = new Application("123.456.78.9");

// Create an instance of Excel.Application
Application app = new Application();

app.setVisible(true); // Nice to see what is happening

// Use Excel objects to get at a range in the displayed Worksheet
Workbooks workbooks = app.getWorkbooks();
Workbook workbook = workbooks.add(null);
Sheets worksheets = workbook.getWorksheets();
Worksheet sheet = new Worksheet(worksheets.add(null, null, null, null));
Range range = sheet.getRange("A1:C3", null);

// New contents for the range -- notice the standard Java types
Object[][] newValue = {
{ "defe", new Boolean(false), new Double(98765.0/12345.0)},
{ new Date(), new Integer(5454), new Float(22.0/7.0) },
{ new Boolean(true), "dffe", new Date() }
};

// For Excel 2000, use: range.setValue(newValue);
// For Excel XP or 2003, use:
range.setValue2(newValue); // Update the spreadsheet
Thread.sleep(10000); // Sleep 10 seconds

// Get the new content of the range
// For Excel 2000, use: Object[][] values = (Object[][])range.getValue();
// For Excel XP or 2003, use:
Object[][] values = (Object[][])range.getValue2();

// Print them out. Again, the values are standard Java types
for(int i = 0; i < values.length; i++){
for(int j = 0; j < values.length; j++){
System.out.print(values[i][j] + "\t");
}
System.out.println();
}

//False means don't prompt to save changes
workbook.close(new Boolean(false), null, null);
app.quit();
}catch(Exception e){
e.printStackTrace();
}
finally{
// Release all remote objects that haven't already been garbage collected.
com.linar.jintegra.Cleaner.releaseAll();
}
}
}

After compiling I get 100 Errors but i know that all these errors are because of the following error:
package com.linar.integra does not exist*
In the documentation of the program it says that if you got the above error that means your CLASSPATH environment variable does not correctly include jintegra.jar

Please can anyone tells me how to correctly update the CLASSPATH???
or if there is an alternative way to access Microsoft office files via Java???

Thanks in advance
MOE
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 24 2007
Added on Sep 26 2007
12 comments
382 views