Excel post process script error
-
I'm trying to do something very simple and just invoke one of the post processing functions
setString(1, 5, 2, "test");
But this is the result
ReferenceError: "setString" is not defined in <eval> at line number 16 in <eval> at line number 16Modules version 3.5.3
-
That error there looks like it's saying that method does not exist...
Can you show some more code and explain what you're trying to achieve?
EDIT:
Looked in the public source, setString(key,value) is the closest thing I can find.
core/src/com/serotonin/util/properties/MutableProperties.java
Perhaps @phildunlap can bring some more light to the situation. -
These are the functions which are supposed to exist in the post process script engine, setString being one of them.
String getString(int sheet, int column, int row) - get a String representation of the value of the cell String getString(String sheetName, int column, int row) - get a String representation of the value of the cell void setString(int sheet, int column, int row, String value) - set a cell to string type and with a string value void setString(String sheet, int column, int row, String value) - set a cell to string type and with a string value void setNumeric(int sheet, int column, int row, double value) - set a cell to numeric type and with a double value void setNumeric(String sheet, int column, int row, double value) - set a cell to numeric type and with a double value void setDate(int sheet, int column, int row, long value) - set a cell to date type and with a long value void setDate(String sheet, int column, int row, long value) - set a cell to date type and with a long value void openNamedRange(String namedRange, boolean append) - open a named range, optionally begin at its last cell void writeStringToNamedRange(String namedRange, value) - write a string value into the next cell of the named range void writeNumericToNamedRange(String namedRange, value) - write a numeric value into the next cell of the named range
-
@psysak said in Excel post process script error:
ReferenceError: "setString" is not defined in <eval> at line number 16 in <eval> at line number 16
Sorry psysak, I'm not much help here. I can't find the code in github to see what should be happening. See if you can log your variables and ensure that you're inside a post process instance, that's the only way I can think of telling that you have inherited those set{dataType} methods.
Fox
-
No problem. I wonder if I'm invoking them wrong somehow but the documentation doesn't state anything specific. They're supposed to be part of ExcelReportUtility
The ExcelReportUtility is available in the post processing script of an Excel report. It enables one to read or write values to cells, and to write values into named ranges. One can "print(ExcelReportUtility);" from the post processing script entry to see a list of functions available. They are, String getString(int sheet, int column, int row) - get a String representation of the value of the cell String getString(String sheetName, int column, int row) - get a String representation of the value of the cell void setString(int sheet, int column, int row, String value) - set a cell to string type and with a string value void setString(String sheet, int column, int row, String value) - set a cell to string type and with a string value void setNumeric(int sheet, int column, int row, double value) - set a cell to numeric type and with a double value void setNumeric(String sheet, int column, int row, double value) - set a cell to numeric type and with a double value void setDate(int sheet, int column, int row, long value) - set a cell to date type and with a long value void setDate(String sheet, int column, int row, long value) - set a cell to date type and with a long value void openNamedRange(String namedRange, boolean append) - open a named range, optionally begin at its last cell void writeStringToNamedRange(String namedRange, value) - write a string value into the next cell of the named range void writeNumericToNamedRange(String namedRange, value) - write a numeric value into the next cell of the named range
-
@psysak
try
ExcelReportUtility.setString(sheet,column,.row,"string")
or create a var that hosts the ExcelReportUtility?
var ERU = new ExcelReportUtility() ERU.setString(sheetNum,col,row,string);
-
Exactly what I just went off and tried and... it works :) Thanks @MattFox
-
Anytime!
:D -
Thanks Fox!
To clarify,
ExcelReportUtility.setString(sheet,column,row,"string")
is the correct syntax. I don't think the instantiation of a
new ExcelReportUtility()
would work. -
@phildunlap maybe this isn't the thread to ask this but it comes up in this context for me. Could you please explain a little bit about DataPointRT to me? CONTEXT_POINTS returns a DataPointRT object with an id and a name. I notice that I can get the ID just by referencing the property directly with .id, however .name is not a thing. How come and how would I get it?
-
You can see the functions in the class, and why it prints the string it does: https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/m2m2/rt/dataImage/DataPointRT.java#L757
So you would have to go through the
.getVO()
function to get the DataPointVO, which has a.name
-
Ooooh ok, thanks Phil
-
You guys don't have some kind of visual representation for how all these things link together do you? I'm not a full time developer so it's really difficult to understand how all these little things bind to each other and why.
-
No such eureka! picture exists. If you clone the code into an IDE you can at least view the definition of one or another function with a hotkey like F3, which can let you scoot around the code faster.
Generally scripts were intended to get something like the name or other DataPointVO information via the DataPointWrapper in the script documentation, like,
p.getDataPointWrapper().getName();