java copy Excel cell content to a word document [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to be able to copy the content of an Excel cell, let's say B3 in tab (or sheet) "my sheet" into a word document.
I know exactly where to put the content of B3 into the word document, but I don't know how I can do it using Java.

I just finished a project that creates an excel workbook from scratch using java. First time doing it, but I would recommend Apache POI. To share some sources I found along the way here is an overview of core classes the library offers with some useful method descriptions.
And if you find this is something you may want to use here are a bunch of examples that I found quite useful.
My answer is as non-technical as they come, but hopefully this is helpful in some way.
Edit: Just to give an example, you could do something like:
Sheet sheet = new Sheet();
sheet.getRow(rowNumber).getCell(cellNumber).setCellValue(someValue);
And you can get fancy and iterate through every row, cell, column, etc. I found it to be pretty flexible. Even offers styling options
Edit2: Just realized you don't need to set the excel cell value. Oh well, there it is anyways. Still a useful library to use one way or the other though.

Related

Best way to display array list in window builder [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
What is the easiest and best way to display array list in window builder?
I'm trying to create simple application to manage database. I have managed to create very simple version with text fields for each part of array list, but i want to go step higher.
Rows must be clickable so i can get information about clicked row to edit it.
I have heard JTable is good but some people say it's not supported for array lists, and i suppose they are right because i couldn't display anything for like an hour now.
I have heard JTable is good but some people say it's not supported for array lists
You should then probably stop listening to the people who told you so. A more reliable source tells us:
A table model object must implement the TableModel interface.
( from here ).
Guess what: that TableModel interface, it doesn't say anything about how the underlying data is stored! It only asks how you get to rows and columns. Which is pretty straight forward when you have a single backing list: you have one column, and each element in your list represents one row in the model.
So, yes, a JTable sounds like a good "next step" for you, as it allows you to easily gain control over editing and clicking. And more importantly, you only need one JTable instance. Instead of having one textfield per List member!

Add multiple values on a table using docx4j [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
The image below describes what I want to do, so I'm supposed to add many values to this three tables.
I'm using the library docx4j
You can use content control databinding for this; docx4j's OpenDoPE convention allows you to repeat table rows. And more recent versions of Word have a concept of repeating content controls; see https://www.docx4java.org/blog/2015/01/word-2013-repeatingsection-content-controls-ready-for-prime-time/
In principle, docx4j supports both, but it'll be easier to get help with the OpenDoPE approach.
To get started, try invoice.docx from https://github.com/plutext/docx4j/tree/master/sample-docs/word/databinding which is an example of repeating table rows.
To merge invoice-data.xml (from the same dir) into it, use https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ContentControlsMergeXML.java
If you like this approach, you'll need to author your own input document; to do this, you can try the "friendly" Word AddIn at https://opendope.org/implementations.html

how to append data in an existing pdf? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm trying to add some data to a PDF with iText 7 in a Java application.
I don't succeed in opening the pdf in append mode. I looked for some solutions online but all concerned iText5 (and use classes that doesn't exist any more.)
What can I do?
It depends on what you want specifically:
merge two documents:
https://developers.itextpdf.com/content/itext-7-examples/itext-7-merging-pdf-documents
add content at the end of a document:
Similar to before, you could create a new document (to a byte output stream), and merge the two together
add content to an existing page:
Hard to do, since that typically requires re-layout of the document, which no PDF-engine can currently do.
fill in forms in the document:
https://developers.itextpdf.com/content/itext-7-examples/itext-7-form-examples
add an attachment to the document:
https://developers.itextpdf.com/examples/miscellaneous/clone-embedded-files
extra (3):
Adding content to a PDF, in the middle of existing content is extremely hard.
To understand why, here is some information on how PDF documents are built internally:
PDF documents contain instructions for a viewer to render, rather than plain text
instructions and their arguments are grouped in 'objects'
objects can be compressed to reduce file size
a PDF document keeps an internal index of all of these objects, this is called the XREF table
the index inside a PDF document uses byte-offsets to tell a renderer where (in the file) an object can be found
Suppose you want to change (or add) something.
You'd mess up all the byte-offsets in the XREF. No viewer would be able to find any object again.
Then there is the fact that the PDF does not contain layout information. If you added something new, and existing content would need to move, you need layout information (what objects make a sentence? which sentences make a paragraph?). Only by having layout information can you sensibly re-layout the document.

XML Document Parsing in Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need to parse an XML document in java for a web service I'm making, and save the contents of it.
I need to save the name of the tags, if the tag has attributes save the attributes, and then save the data within those tags. These three items will be inserted into a database table with the three columns tags, attributes, and data.
I'm using the following java libraries:
javax.xml.parsers.DocumentBuilder
javax.xml.parsers.DocumentBuilderFactory
org.w3c.dom.Document, org.w3c.dom.NodeList
org.xml.sax.InputSource.
Any help would be much appreciated.
DISCLAIMER: I don't want to plagiarize so I didn't include code but included links to other tutorials that are VERY helpful to this topic.
First, you should read w3c dom's java API because it tells you a lot of useful functions that are very related to your question.
Second, this website contains a useful tutorial that's easy to understand and it contains the necessary information for you to get the attributes of tags.
Third, this website gives you info on how to get tagName when you are looping through elements.
Fourth, you should always read related API, google, and then post a question if you are have no clue after a LONG period of time.
Lastly, you should post a difference question or research on database FIRST before asking that question here. This question should only be about XML Document Parsing in Java.
We are not supposed to help you do anything so the API is the best help for you (and google).
API: https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/package-summary.html

How can I format Java code in word document [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need to write a report which may contain some Java code pieces. I need the code to appear colored and line numbered. How can I do this ?
Go to http://hilite.me/ and copy from the preview pane directly to word (tested with MS Word2007). Supports line numbering, but not well. Quite good for snippets.
One way is to copy & paste directly from Eclipse. It preserves all the color formatting.
- Well you can directly copy the things from an IDE to your Word Document.
- And please make sure that you have switched on the Line Numbering of the Editor in the IDE before copying the code.
try to use this:
http://quickhighlighter.com/
select with the line numbers copy and paste
You can also use another online formatting tools, (http://stackoverflow.com/questions/206441/online-code-beautifier-and-formatter) but if you want the coloring to work after inserting to a word document, the highlihted source code html source must be inline styled.
You can copy with colors, but first you have to open all fold otherwise colors gone.
Line numbering copy is not working from Eclipse.
Explanation with example:
https://cmanios.wordpress.com/2012/03/08/copypaste-source-code-from-eclipse-to-microsoft-word/

Categories

Resources