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.
Related
Good day to all. I am currently building a program that covers the review of product warranty applications. I'm doing it in javaFX using Netbeans. The program has the following scenes:
a screen where the information of each guarantee request is entered. all the information is stored in a table in a database. The interaction between the program and the database is done, in effect, through JDBC.
a screen where you can see a table that shows all the requests that have been saved. if a row is selected, a button that carries the third scene all the data of the request that was selected is enabled.
a screen where all the data of the tests that are made to the selected guarantee application are entered. The results are also stored in another table in the database.
After the application is evaluated, a warranty review report must be generated. Currently this format is generated in pdf from excel. What I want to do is that from the data results of the tests stored in the database I can dynamically generate the pdf formats from the program in javaFX. Is there a plugin to write these documents automatically? I'm good at writing texts in LaTEX, so if there is a way to generate the latex format from the program and call the necessary information from the database, it would be perfect. Thanks in advance for the help. Any indication or idea is welcome.
It seems like you have two core requirements:
Fetch data from the database suitable for reporting
Generate the report(s) in PDF from JavaFX but can fall back to LaTEX
What you really need seems like a PDF library for Java. I can suggest iText and Docmosis as good options (please note I work for Docmosis) - both are commercial for commercial products so you would have to buy.
Assuming you are using one of these libraries, the process for each report is:
execute the query to fetch the appropriate data for the report
manipulate the data if required to make the reporting stage simple
generate the report
Using iText you would write the query, the manipulation code and then the code to layout the report including the data.
Using Docmosis you would write the query, possibly some manipulation code (Docmosis can also work directly with your ResultSet) and the code to execute the report. The layout is designed in the template (Word or Libre Office Writer).
When you mention writing "these documents automatically" I assume you mean creating the PDF file format, which iText and Docmosis can do. If you mean creating the report layout itself, then you always need to design/write something to make the report do what you require.
I hope that helps.
Thank you very much for your response Paul! I had found something related to the libraries you mentioned, and indeed something like what I'm looking for. I notice that you are more in the subject. then, you do not know bookstore, preferably free, that gives me the possibility of doing the following (pseudo code):
take the row from the database
Save the information of that row in the attributes of a created class.
create text1: "the guarantee with reference" + object.attribute1 + "was not approved in view of the physical revision test indicated that" + object.attribute2 + "
create text2: "..."
...
create the text n: "..."
take text 1 and place it in the header of the pdf document
Take text 2, put it in bold and place it in the subtitle
Generate a table and fill it with the content of text 3, 4 ...
compile all information as a pdf, (word file, xls or others if possible)
I am clear that with the libraries that you recommend you can easily make items from
1 to 8, but I do not know if it is possible to enter the texts within a template created, so that the library accommodates all the texts in the respective zones of the template file. I imagine that this can easily be done with Latex, since everything is written in plain text.
I found a library called Java LaTeX Report (JLR) that allows me to do what I want. This information may be useful to someone. Thank you again for your answer Paul, if you consider the libraries that you mention do the job more easily than JLR please let me know!
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.
I have created a program that should one day become a PDF editor
It's purpose will be saving GUI's textual content to the PDF, and loading it from it. GUI resembles text editor, but it only has certain fields(JTextAreas, actually).
It can look like this (this is only one page, it can have many more, also upper and lower margins are cut out of the picture) It should actually resemble A4 in pixel size.
I have looked around for a bit for PDF libraries and found out that iText could suit my PDF creating needs, however, if I understood it correct, it retirevs text from a whole page as a string which won't work for me, because I will need to detect diferent fields/paragaphs/orsomething to be able to load them back into the program.
Now, I'm a bit lazy, but I don't want to spend hours going trough numerus PDF libraries just to find out that they won't work for me.
Instead, I'm asking someone with a bit more Java PDF handling experience to recommend me one according to my needs.
Or maybe recommend me how to add invisible parts to PDF which will help my program to determine where is it exactly situated insied a PDF file...
Just to be clear (I formed my question wrong before), only thing I need to put in my PDF is text, and that's all I need to later be able to get out. My program should be able to read PDF's which he created himself...
Also, because of the designated use of files created with this program, they need to be in the PDF format.
Short Answer: Use an intermediate format like JSON or XML.
Long Answer: You're using PDF's in a manner that they wasn't designed for. PDF's were not designed to store data; they were designed to present and format data in an portable form. Furthermore, a PDF is a very "heavy" way to store data. I suggest storing your data in another manner, perhaps in a format like JSON or XML.
The advantage now is that you are not tied to a specific output-format like PDF. This can come in handy later on if you decide that you want to export your data into another format (like a Word document, or an image) because you now have a common representation.
I found this link and another link that provides examples that show you how to store and read back metadata in your PDF. This might be what you're looking for, but again, I don't recommend it.
If you really insist on using PDF to store data, I suggest that you store the actual data in either XML or RDF and then attach that to the PDF file when you generate it. Then you can read the XML back for the data.
Assuming that your application will only consume PDF files generated by the same application, there is one part of the PDF specification called Marked Content, that was introduced precisely for this purpose. Using Marked Content you can specify the structure of the text in your document (chapter, paragraph, etc).
Read Chapter 14 - Document Interchange of the PDF Reference Document for more details.
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?
I am currently writing a program which takes user input and creates rows of a comma delimited .csv file. I am in need of a way to save this data in a way in which users are not able to easily edit this data. It does not need to be super secure, just enough so that it couldn't accidentally be edited. I also need another file (or the same file?) created to then be easily accessible (in the file system) by the user so that they may then email this file to a system admin who can then open the .csv file. I could provide this second person with a conversion program if necessary.
The file I save data in and the file to be sent can be two different files if there are any advantages to this. I was currently considering just using a file with a weird file extension, but saving it as a text file so that the user will only be able to open it if they know to try that. The other option being some sort of encryption, but I'm not sure if this is necessary and even if it was where I would start.
Thanks for the help :)
Edit: This file is meant to store the actual data being entered. Currently the data is being gathered on paper forms which are then sent to the admin to manually enter all of the data. This little app is meant to have someone else enter the data from the paper form and then tell them if they've entered it all correctly. After they've entered it all they then need to send the data to the admin. It would be preferable if the sending was handled automatically, but this app needs to be very simple and low budget and I don't want an internet connection to be a requirement.
You could store your data in a serializable object and save that. It would resist casual editing and be very simple to read and write from your app. This page should get you started: http://java.sun.com/developer/technicalArticles/Programming/serialization/
From your question, I am guessing that the uneditable file's purpose is to store some kind of system config and you don't want it to get messed up easily. From your own suggestions, it seems that even knowing that the file has been edited would help you, since you can then avoid using it. If that is the case, then you can use simple checks, such as save the total number of characters in the line as the first or last comma delimited value. Then, before you use the file, you just run a small validation code on it to verify that the file is indeed unaltered.
Another approach may just be to use a ZIP (file) of a "plain text format" (CSV, XML, other serialization method, etc) and, optionally, utilize a well-known (to you) password.
This approach could be used with other stream/package types: the idea behind using a ZIP (as opposed to an object serializer directly) is so that one can open/inspect/modify said data/file(s) easily without special program support. This may or may not be a benefit and using a password may or may not even be required, see below.
Some advantages of using a ZIP (or CAB):
The ability for multiple resources (aids in extensibility)
The ability to save the actual data in a "text format" (XML, perhaps)
Maintain competitive file-sizes for "common data"
Re-use existing tooling support (also get checksum validation for free!)
Additionally, using a non-ZIP file extension will prevent most users from casually associating the file (a similar approach to what is presented in the original post, but subtly different because the ZIP format itself is not "plain text") with the ZIP format and being able to open it. A number of modern Microsoft formats utilize the fact that the file-extension plays an important role and use CAB (and sometimes ZIP) formats as the container format for the document. That is, an ".XSN" or ".WSP" or ".gadget" file can be opened with a tool like 7-zip, but are generally only done so by developers who are "in the know". Also, just consider ".WAR" and ".JAR" files as other examples of this approach, since this is Java we're in.
Traditional ZIP passwords are not secure, and more-so is using a static password embedded in the program. However, if this is just a deterrent (e.g. not for "security") then those issues are not important. Coupled with an "un-associated" file-type/extension, I believe this offers the protection asked for in the question while remaining flexible. It may be possible to entirely drop the password usage and still prevent "accidental modifications" just by using a ZIP (or other) container format, depending upon requirement/desires.
Happy coding.
Can you set file permissions to make it read-only?
Other than doing a binary output file, the file system that Windows runs (I know for sure it works from XP through x64 Windows 7) has a little trick that you can use to hide data from anyone simply perusing through your files:
Append your output and input files with a colon and then an arbitrary value, eg if your filename is "data.csv", make it instead "data.csv:42". Any existing or non-existing file can be appended to to access a whole hidden area (and every file for every value after the colon is distinct, so "data.csv:42" != "data.csv:carrots" != "second.csv:carrots").
If this file doesn't exist, it will be created and initialized to have 0 bytes of data with it. If you open up the file in Notepad you will indeed see that it holds exactly the data it held before writing to the :42 file, no more, no less, but in reality subsequent data read from this "data.csv:42" file will persist. This makes it a perfect place to hide data from any annoying user!
Caveats: If you delete "data.csv", all associated hidden data will be deleted too. Also, there are indeed programs that will find these files, but if your user goes through all that trouble to manually edit some csv file, I say let them.
I also have no idea if this will work on other platforms, I've never thought to try it.