
-----------------------------------
rto
Tue Jun 10, 2008 7:56 am

opening excel
-----------------------------------
Alright guys, not even sure if thsi is possible, but i will attempt to make this understandable. I am maknig a program in which an excel file needs to be opened. basically its something like this :

c.println ("are you a customer or an admin?");
status = c.readString
     if (status.equalsIgnoreCase ("admin"))
     c.println ("would you like to view or change the database files?");
            if (status.equalsIgnoreCase ("view"))
            //OPEN EXCEL FILE HERE FOR VIEWING! ! ! 
            if (status.equalsIgnoreCase ("edit"))
            //OPEN EXCEL FILE HERE FOR EDITING! ! !

some of this stuff may be off so i dont really need editing tips, i just need to know two things
1) how do i open an excel file to view?
2) is it possible to open an excel file and edit it? if so, how?

-----------------------------------
jeffgreco13
Tue Jun 10, 2008 8:24 am

Re: opening excel
-----------------------------------


public class openExcel {
public static void main(String 

That's a main method if you notice. I'll let you play around and add it as a method you can call within your program.

-----------------------------------
rto
Tue Jun 10, 2008 8:35 am

RE:opening excel
-----------------------------------
i will most certainly give that a go, i will reply today durnig my fourth period (in first now) to let you know if it worked, thanks

-----------------------------------
rto
Tue Jun 10, 2008 11:03 am

RE:opening excel
-----------------------------------
errors: 
line 1:
"public" is not a valid modifier for a local inner class
line 2:
The static method "main" is invalid, because it is enclosed in an inner class, "openExcel", located at C:/Users/john/Documents/Java/ISP.java:36.
line 4:
Type ProcessBuilder was not found

.. .. .. no clue

-----------------------------------
Aziz
Tue Jun 10, 2008 11:08 am

RE:opening excel
-----------------------------------
You need some more understanding of Java if you don't understand that code.

Do you know what a class is, and a "main" method? And you'll need to know about importing. Also, google "java 6 ProcessBuilder" to find the javadoc for that class.

Another thing you could do is parse the Excel file youself. That's probably more complicated than it's worth, however.

Also,jeffgreco12, classes (especially in java), are named LikeThis not likeThis. It only convention, but it's like saying it's a convention not to rape little children.

-----------------------------------
jeffgreco13
Tue Jun 10, 2008 11:28 am

Re: opening excel
-----------------------------------
Taht's absolutely right aziz... i slipped up there.

You need to import the correct javadoc. Search on google like Aziz said and it will tell you which one.

Why don't you show us what code you have written already. Im guessing that the code you asked for is only going to be a part of a bigger program right?

-----------------------------------
rto
Tue Jun 10, 2008 9:21 pm

Re: opening excel
-----------------------------------
Alright, let me first specify this: i am no java wizard nor do i claim to be. this is my isp for my ICS3M course (grade 11 programming for those who do not know) and i need the assistance. here is the code:

-----------------------------------
Tony
Tue Jun 10, 2008 9:59 pm

RE:opening excel
-----------------------------------
And this is exactly why it's a bad idea to teach with Java, skip the fundamentals of "class", "public", "main", but require the students to use all of the above anyway. Brilliant!

-----------------------------------
rto
Tue Jun 10, 2008 10:18 pm

RE:opening excel
-----------------------------------
helpful tony :P anyways, im goin to bed, thanks for the help guys, anything else will be excellent talk to ya tomorrow

-----------------------------------
jeffgreco13
Wed Jun 11, 2008 8:56 am

Re: opening excel
-----------------------------------
Have you tried inserting this code into a method?

Here try this: 

public runapp(String pathname, String app) {
try {
ProcessBuilder proce=new ProcessBuilder(app, pathname);
proce.start();
}
catch(Exception e) {}
}


Now out of practice, I want YOU to figure out how to implement this in your program.
Hint: you may need to run a new process each time  :wink: 

I did quickly write this without an IDE so if there's any errors let me know.
