Generating dynamic forms from Excel xlsx to HTML and JavaScript - java

I am trying to create dynamic forms for a web application using Excel spreadsheets.
The form has some relatively advanced rules like the following:
Field A > Field B.
Field C must be shown if Check Box D is checked.
Field E is read-only and must be a sum of A and B.
Field G is sum of E and A or F and A if B is empty.
Combinations of rules.
These are just examples of some of them.
The server is implemented and runs in Java which I guess narrows the possible solutions. My first thought is to parse the excel spreadsheet with all required information into XML to enable either serverside or clientside conversion. This is basicly because I have found tools that work on either side.
So my question is whether anyone knows of a tool that can perform this conversion or if anyone knows of a better solution?
I have looked at https://github.com/davidmoten/xsd-forms but I am not sure it can implement all the required rules and license information is sparse.
I realize this question is quite vague but so is the task. Any help is appreciated.

I think you can use Apache's POI API for reading Excel sheet and JAX-B for generating XML from the data read from excel sheet.
You can read the more details about reading excel files using Apache's POI API over here.

Related

Explain excel formula in PRD

I have an excel template which needs to be automated by the developer using JAVA, the problem here is that the developer is not well versed with excel and want all excel formula in detail in PRD document.
It would be great if anyone can guide me here to how to explain excel formula most effectively in PRD document or is there any other better option to explain all the details in excel as well.
There are very many examples (though a minority!) here on SO of how to "explain" an Excel formula. The essence of the process is:
work from the inside out
apply Evaluate Formula (from the Formula Auditing tab)
refer to https://support.office.com for details function by function
For presentation judicious use of Alt+Enter can be very helpful where formulae are complex - to insert line breaks to split logical components.
(The above are also the main steps in debugging issues with a formula, though for that some overwriting of data is also often very helpful - so reliance is not on what seems to be the data but what is known to be, particularly for format, precision and spaces.)

How to find a specific string in 1 or 2 sheets of a excel file using Apache POI?

I need to find an specific string (id, name for example) in 1 sheet of excel.
this is a basic need.
Later on we need to find a user on several excel sheets and copy the whole record identified with that code and send it to a JTable in the frame.
Are you looking for a high-level search function or something? I don't think that exists.
As you load the sheets, you might consider just adding the interesting columns to a HashMap if you can use exact matches, otherwise just iterate over the sheets/columns/rows and search manually.
You could create some mid-level tooling to do this. A "Sheet Indexer" perhaps, that takes a sheet and a list of columns then lets you do lookups. Even if you have to write code to iterate over everything manually you shouldn't worry too much about speed--the number of sheets/rows are very unlikely to get large enough to effect performance or anything.
We actually have a lot of tooling built around poi including a ORM layer that lets us load from spreadsheets using annotations just like hibernate. We called it "son of poi" aka "poison".

couldn't get/set checkbox value in Word document (.doc) with Apache POI

I'm trying to get/set checkbox value in Word document (.doc) with Apache POI.
I looked HWPFDocument API at poi.apache.org, but haven't found anything suitable...
Maybe somebody have a solution?
Thank You!
Unfortunately, this is currently not supported by POI. What does work is to read out (not set) dropdown lists via CharacterRun.getDropDownListValues() and CharacterRun.getDropDownListDefaultItemIndex().
Technically those dropdown lists are closely related to checkboxes, though. So it should not be too difficult to add the respective functionality to POI, if desired. Your entry point is a NilPICFAndBinData structure (handled by this class in POI), which leads you to some FFData (maps to this class in POI). Inside that you will find FFDataBits. These eventually contain an iRes value which encodes the status of that checkbox.
- This is exactly the same behavior as for dropdown lists, only that the iType of FFDataBits will be iTypeChck instead of iTypeDrop and has to be interpreted in a slightly different way.
I had the same problem. Had to write a VBA macro that gets the value of the checkboxs, stores it in a portable database and I get it from there.

Secure? Converting Excel functions into Web Script

I understand that I can convert Excel files into web scripts through converters such as Apache POI (into Java) or PHPExcel (into PHP). However, the Excel file I am trying to convert contains a lot of trade secret and proprietary information. How can I secure it?
For example, if I have excel function "11+a=b," I want the website user to enter "value A," press calculate, and webpage return "Answer B" to the user without letting the user know the formula "11+a=b."
Is this possible?
You have misunderstood what these libraries do.
They allow you to read Excel documents so you can access the raw contents of e.g. cells from within your own program. If you need to do anything more than that - like recalculating the value displayed of a cell - you need to provide additional code yourself.

Need suggestion on reading huge XLs with validating the data

I have a requirement where client uploads spread sheet containing thousands of rows.
different columns of a row have different data type and the data must comply with some validation rules.e.g.
below is a sample file structure:
(Header - Colume_name,Variable_type,field_size,i/p mask,required_field,validation_Text)
(P/N,String,20,none,yes,none)
(qty,Integer,10,none,yes,none)
(Ship_From,String,20,none,yes,none)
(Request_Date,Date,MM/DD/YY ,yes,none)
(Status,String,10,none,yes,Failed OR Qualified)
while reading the xl sheet,I need to validate the data against the above constraints and in case of any error in the data,
I need to store the error and inform the customer.
Please let me know the best possible approach maintaining the performance of the system.
Any early responses will be much appreciated.
Thanks,
Ashish Gupta
If I understand your question, you would like to read a file of validation rules such as the sample above. You would like to compile the rules such that they would read a large Excel spreadsheet (or is it a CSV file?) and perhaps print out a message for every line that is deemed invalid.
It seems like a two-pass process:
1) Validation and compilation of the validation file and 2) Compilation of the output of pass 1 and applying it to the Excel file.
You could approach the field validation in any of several ways, depending on your skills and inclinations.
Develop VBA code to read the validation file. Then write a separate macro to validate each line
Write a parser in your favorite language that reads in the validation file. Add some columns to the read-in Excel spreadsheet with fields such as Column name (e.g., Qty), type (e.g., Integer), required (e.g., true). Then have Excel or OpenOffice highlight invalid lines
Have lex and yacc generate Java or C++ a parser to scan the validation file and output BNF. Then have another lex and yacc file read in the output from the previous step and have it validate the Excel file.
You indicated POI on your tag, so I'm thinking that you will want to generate Java code.
Of course, you could also write a one-time program to do all of this meta-compiling and compiling, but this would be a brittle process.
If you have any freedom to specify the validation file, you might want to make it an .XSD file because there are automated tools to make its scanning much simpler. There are tools to determine whether the XML file were valid, as well as compilers that can turn it into Java.
(A thought came to mind when I was reading your validation file. How will you separate one part from another? For example, if you read in P/N, Qty, Request_Date, Ship_From, Status, P/N, is that one part with two P/N or one complete part and one with several required parts missing?)
My first thought was to have Excel do this validation, as Rajah seems to suggest too. Built-in functionality and/or VBA should be able to handle these requirements.
If you need to handle this in Java, I'd go for the XML approach.
Cheers,
Wim
I heard about a friend validating his spreadsheets using JBOSS DROOLS: http://www.jboss.org/drools
I have a XML based excel validator built on top of POI.
You just need to specify which data you need to validate in excel, the java api does the validation & returns the error message if not valid.
Eg:
<data rowNumber="2" columnNumber="2" dataType="string" >
<mandatory errorMessage="Name label is missing">Y
<value ignoreCase="true" errorMessage="Name label value is not matching.">Name</value>
The above is a simple validation for a plain text field, it has additional validations too, please let me know if you are intrested?

Categories