Can anybody please let me know how to read the values of Excel form controls (radio button, checkbox, drop-down etc) in Java?
I tried using Apache POI, but I couldn't find a way to read the value of radio buttons or checkbox.
I know that I can link the form control with a particular cell in excel, and when the value of form control changes, read the data from that cell. But, instead of following this approach, I am looking for a way to directly read the value of form control.
I searched google but couldn't find anything useful. So can anybody please help me here?
I do not have any limitation of using any API's. So please let me know if this can be done in Java or not.
Related
I am creating automation that automatically sends messages through LinkedIn. The code is working fine, but as per our current requirement, I want to click on the attachment button so as to pass the attachment also with the text message. There are a few points that I have already tried:
Unable to fetch the element ID as its dynamic most of the time.
Don't want to use offsets (x,y) because once anyone changes the size of the window offsets changes.
Unable to use XPath.
Then I checked for another tool "UIVision" which makes a solution to capture that particular area (save it in a .png file) from the page where we want to click and during runtime it clicks there. So I tried searching image comparison API for java, tried with ASHOT and Sikulix too but none worked for me.
Anyone can help me with this?
When you say your unable to use xpath will you please elaborate?
The button has an id - it's attachment-trigger-ember1079.
If you're concerned about the latter part being dynamic, the attachment button also has a good title.
You can try using xpath string:
//button[contains(#title,'Attach a file')]
For me, on my linked in, this returns a unique hit on the expected attachment object:
If these don't work, there's also the option of using javascript to action the upload.
For more information on handling the upload dialog (after your identify the object) have a look here
Let me start off with saying that I've seen some questions in this regard but nothing actually specifically answering my issue.
Let's say I have a template version of a PDF received by someone else. It's a classic PDF that looks like a form but only one part is editable, the other parts are not because they are being filled in with data from an imported excel sheet. (Sadly I can't show an example)
I've been able to do most in iText 7 but I can't figure out for the life of me if I can change a flat text field into an editable form field, like on image 1.
Image 2 shows checkboxes that I want to make editable as well but I can only change their value within java and even then it only shows a cross, not a checkmark (even if I change the checktype).
It's a bit hard to explain but tl:dr is that I just want to know whether I can edit an existing flat PDF in java or if I have to do so in adobe itself.
Thanks
I am using Kettle for data migration for moving data, I come across a scenario where i got a excel where the column header is merged, When i read it only the first cell gets the name others are empty, Kettle can only duplicate values vertically, I have a macro which does the exact same thing, But some one has to do it manually, Is there a java code i could run to achieve this?
What do you mean by merged? In the excel file is there one cell with all the values? Is there a separator? If it's not a great deal of columns I'd just manually add them or change them to what I want using a select step. If you'd like to upload files I'll take a look.
I think, got the solution. Here Java code is not required. Please follow the step to achieve your result.
Step1: Drag and drop Microsoft Excel Input to the canvas.And go to Content uncheck Header.
Step2: Go to !Fields tab. See the below image and fill up like below image.
Step3:Go to Additional output fields tab and then check for sheet row nr field and fill up the check box with row_number.
Step4:Finally, click on preview button. You get the result like below.
If you see the result. First three rows are unnecessary. You can filter those three rows by using Filter step this part I'am not done.
I'm trying to generate an xsl to be printed in a pre-printed sheet which works fine.
Now i want to give the user a better previsualization (in the pdf screen version) adding a background image which emulates the "pre-printed" stuf on the sheet to give the user a "context" of what is he printing.
The question is: Is there any way I can set a background image in xsl (using apache fop) visible only in pdf but not in the printed version of it?
Thank you all for reading or givin any advice.
Although as the comments state, you can't have content in the PDF that does not come out in a physical printed copy, here is one possible work around for you. Depending on how your users are ultimately going to be using FOP for PDF rendering and how your a driving the work flow, it's possible to pass a parameter into an xslt file before the transofrmation phase is run, so potentially, you could do a dual rendering of the same PDF, one that is presented to the user where the background image is enabled, and one that gets printed, you could just set a variable similar to how they do in this Example, and call it something like $isPreview, and just use a simple if or choose statement to check for 'Y' or 'N'.
Since you are sending to a printer, you may even want to take advantage of FOP's ability to generate to Postscript rather than PDF, I've used this feature quite extensively for print documents using FOP while also producing a PDF copy for electronic delivery via email or hosted services, and I've yet to find any discrepancy between the PDF rendering and what is printed after sending a rendered postscript file, so it should work well for you as well.
As I said, this is not truly a solution to your problem as you've presented it, but as a work around, it could get you the desired results if your clever about how you implement it.
I don;t think the statement that it is not possible is true, I am just not sure how to create such a PDF with FOP. Certainly you can add an image field. One would use a button field and place the image in the button. Then you would set the properties of that button to not print (printable false).
PDF support images in fields: https://answers.acrobatusers.com/adding-image-field-form-q41825.aspx
RenderX supports PDF Form fields but I do not see where they support an image inside the button, only text: http://www.renderx.com/reference.html#PDF%20Forms. But they do support setting a field to "printable".
I'm using DocX4J for creating an excel file. Now I want to give some rows a background color, depending on a calculation done before creating the excel.
However, I can not find a method or something to add a backround color for a row.
The Java-Doc is also not very helpful.
I thought about coloring each cell, but cells also don't have a proper method. (They don't have any proper-named methods at all ...).
Anybody knows a hint? It is really difficult to find some documentation ...
I think you need to add a row element to worksheet/sheetData, for example:
<row r="2" s="1" customFormat="1" />
and corresponding entries in the styles part. Look at fills, cellStyleXfs, cellXfs.
You can research these by looking them up in the spec, at http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/index.html
When you are ready to code, you can upload an xlsx which contains whatever it is you want, then click to have code generated for you.
In short, your best approach, once you have a basic understanding of Open XML parts and docx4j's JAXB based approach to them, is to use the code generator, and the spec, and beyond that, docx4j's source code.