Forum Discussion

FICO's avatar
FICO
Community Manager
15 years ago

Blaze Accessing External Local Files

Blaze Accessing External Local Files

I am testing some functionality by attempting to access an excel file on my machine, locally. I have imported the jar file which contains all the classes and methods that I would need to do so. The code compiles and is logically sound, but I get a runtime error indicating the that file I am trying to access was "unknown." I can surmise that the path to the file is wrong or that I do not have the necessary classes to handle this code.

Question:

1. Does Blaze share Java's file access protocols (program can only access a file within its current directory, sub directory, or special access is granted)?

2. Is there a better way to read/write to local files with Blaze?

Test Code (an excel file with jxl.jar imported):

a1 is some Workbook;

a1.getWorkbook(io_File.newInstance("C:\\Blaze\\Advisor67\\Test Excel\\Book1.xls")); b2 is some Sheet; b2 = a1.sheet[0]; print("" b2.getCell(1,1));

Runtime Error:

com.blazesoft.engines.rules.NdEvaluationException: Evaluation error

Expression produces unexpected value: unknown. unknown while evaluating t.newInstance("C:\\Blaze\\Advisor67\\Test Excel\\Book1.xls")

The ultimate goal is to read an excel file, format the data into xml test files, and then to read those xml files for test runs.

Thank you.

2 Replies

  • FICO's avatar
    FICO
    Community Manager

    From the code that you have posted below, I can see that you are declaring a variable with the name a1 and you are trying to use it before the variable has been initialised.

    You need to use "a/an" keyword or a "newInstance(...)" method to instantiate a class and assign that object to the variable before using the same.

    Good luck.

  • FICO's avatar
    FICO
    Community Manager

    Thanks, realized I had forgotten that I needed to set a1 when getting the workbook.

    a1 = Workbook.getWorkbook(io_File.newInstance("C:\\Blaze\\Advisor67\\Test Excel\\Book1.xls"));