Adding two columns in a single cell of excel using POI - apache-poi

I am creating an excel using poi jar and I have the following issue.
I have two columns coming from DB.
I have to add these columns in a single cell. one column with left alignment and one column with right alignment.
The cell should look like
----------------
|A B|
----------------
Any suggestions ???

Related

Is it possible to change 0000000,00 to 0000000.00 with maual formulas or vba code?

I have a data set with values to export from excel to file txt and therefore, they need to have specific formatting, such as the column of values (as explained below).
My columns are: Year | Month | Company | Number | Value | Note
At the column "Value" I have this format (custom): 0000000,00;-0000000,00
I would like to change comma to dot in order to have this aspect: 0000000.00.
In the table I have, for example: 0000015,70 and I would like to change for 0000015.70
Is it possible to change through manual formulas or vba code?
If you change your custom format to 0000000.00;-0000000.00 and then SaveAs TXT, EXCEL writes that column in that format.
It is also possible to have those values repeated in a new column, but with the desired format, by using a formula LIKE =text(E2, "0000000.00").

Excel apply formula after pasting table

Is there a way to create an excel template, which automatically applies a formula if a certain column is inserted? The use case would be:
User copies a table from a desktop program (CSV or Tab separated)
Pastes the table into the excel template
Somehow the column's header gets matched (header's name is fixed)
Multiply the column values with a fixed value (like 1.25)
The problem is that the column could be in different indexes and the formula should apply to all the rows, not just fixed ones, but my main problem is how can I get a copy-paste event and find the column.
Edit.: I can only do this with VBA (never used it before)?
Assuming the column header is constant you could insert a table with "dummy" headers and a calculated column using the header name as a reference
In the example I have put a formula in the Calc column. I've put the Calc in column G assuming your maximum import columns are six and because it's good practice to do your calculations from left to right.
You could move the Calc to column A and reduce the "dummy" columns to just 1 with whatever your desired heading is.
To make a template, delete row 3 and clear out the dummy data, just leaving the calculation(s) and save as a .xltx in your profile template folder (wherever that may be in your versions of Windows/Office).
When you paste in your import data the table will extend down and copy the formula(s) automatically. If you have moved your calculation(s) to the left of the table, the table will resize to the right to accommodate all your imported columns.
While the MyHeader column in your template may be over-written, if it can still be found in `Table2[#Headers] the formula will still work.

Comparing every row in table on first sheet with a selected item on second sheet and display it in second sheet

I have the following problem:
I have a file with two sheets. On the first sheet I have a table with some some facts. The important column is where the table contains the version of different application.
At the second sheet there I can select an project from a list and in a second cell there I can select previous versions of the selected project. Between the list with the versions and the list of my projects are a dependency which are on another sheet but that's not so important.
Now I get the problem. If I selected a previous version I want filtering my table on the first sheet with the selected version and every row which is less than the version should displayed at my second sheet.
Has Excel any formula which can solve my problem or have I to use VBA? I don't have any experience in VBA.
Edit:
Okay, let's say my second sheet looks like this:
----------List with selected project -------- list of selected app-versions---------------
|
|
|
----------Headline A ------- Headline B --------- Headline C -------- Headline D ---------
If I have changed/selected an (old) version of my application there should be an event that is triggered.
The event should iterate through my first sheet which looks like:
----------Headline A ------- Headline B --------- Headline C --------- Headline D --------
|
|
|
----------cell A2 ---------- cell B2 ------------ cell C2 ------------ cell D2 --------
----------cell A3 ---------- cell B3 ------------ cell C3 ------------ cell D3 --------
----------cell A4 ---------- cell B4 ------------ cell C4 ------------ cell D4 --------
----------cell A5 ---------- cell B5 ------------ cell C5 ------------ cell D5 --------
In every iterated row it should compare the content of cell A2/3/4/5 with my selected project and the content of cell C2/3/4/5 with my selected app-version if the number of version is greater.
If both matches a passed specific cells should displayed at the columns in the second sheet.
I don't have MS Office on my Mac so I can't take any screenshots. I hope it's more clear what I wanted to do.
Short answer:
most likely, you need VBA.
More detailed answer:
Your English is not 100% clear, so I do not understand whether you wish to "filter", as you wrote, which has the effect of hiding some rows in the first and second sheets, or all you need is simply to highlight and/or not show the content of some cells.
if all you need is the latter, simple formulas plus some simple conditional formatting are enough (no VBA).
but if, as it seems, you need to hide rows or to refresh 2 filters, then you need a handful of lines of VBA, most of which can be recorded as macro.
Pivot tables would not be enough because you want one operation (selecting a framework/version) to affect two worksheet.
Simple formulas would not be enough because filters do not update when the values of calculations change.
What you ask can be done in formulas (I did so in a project), but such formulas would be complex in order to show partial copies of both tables with their rows in a different order.
Also, you seem to ask how to filter the original tables, not how to show copies of the original tables.
In conclusion, the best solution in most cases, would be to learn how to write the few lines of VBA.

Easy way to normalize Excel worksheets?

I have several fairly good-sized Excel worksheets (indexed by WorksheetID) that essentially amount to flat database tables: rows are the records (indexed by DataRecordID within one worksheet), columns are the fields (indexed by DataFieldID within one worksheet), and the cells contain the field values (Value) for the appropriate records (or are blank).
I'm interested in breaking them apart to (many) records like this so that I can import them into MS Access:
ID | WorksheetID | DataRecordID | DataFieldID | Value
I've already done this manually. I see that it's probably a straightforward matter to write a VBA script to chug through the sheets and (optionally) delete the records in the final table.
My question is: Before I roll up my sleeves and begin coding, is there already a built-in capability in Excel 2010 that I don't even need to write a script to do this?
You don't need a script for this provided the data sources are of consistent layout. The basic process is described (with pictures!) here. However since that was considering a single matrix you will need a few extra steps:
Build in to the DataRecordIDs indication of their worksheet origins. Say with a formula such as =A2&"|WorksheetID" copied down to suit in a column inserted as a (new) ColumnB, for all sheets, assuming your first DataFieldID is in A2.
At Step #4 of the process (Step 2b of 3 in the Wizard) you would need to add the relevant ranges from each sheet individually.
Once you have the results Table you would then need to insert a new ColumnB and apply Text to Columns, Delimited with Other | to ColumnA.

Colour formatting according the type of the item in Excel 2010

I started building an excel spreadsheet with a database of items in Microsoft Excel 2010. Those items have some fixed max values on its properties according the type of them. Those values are stored in another hidden table according the type of the item and of course are different in each of them. For example the hidden table its something like this:
Type | Price | Warranty
TV | 1683 | 4
PC | 1210 | 1
A/C | 1234 | 2
So now whenever i create a new item in my main table those properties will get a data bar color formatting compared to the other hidden table! Like:
TV | Sony Bravia RT219 | 1293 | 2
...and those "1293" and "2" values needs to get a data bar "comparing" the "1293" value with the max "1683" and so on...
I wish that you can understand me. Which formula i have to use so i can make this possible in ms excel 2010?
You can probably do what you want using worksheet functions (no vba) and conditional formatting
=INDIRECT(ADDRESS(MATCH(A1,Sheet2!A1:A3,0),2,1,1,"Sheet2"))
Sheet2!A1:A3 is a reference to your hidden list, mine only has 3
It looks at the value of A1 on the first sheet, tries to find it in the hidden sheet.
If it finds a result, MATCH() returns its row number.
ADDRESS() then returns the address of the 2nd column on the MATCH() row in sheet2
INDIRECT() then gets the value of it.
MATCH(LOOKUPVALUE,LOOKUPLIST,MATCHTYPE)
ADDRESS(ROW, COLUMN, ABSOLUTE, A1/R1C1, SHEET)
INDIRECT(ADDRESS)
you should be able to have it pull all the information from the 2nd sheet using that.
dont have time to explain anymore, but the functions aren't that hard to figure out
update
made a simple example https://dl.dropbox.com/u/10316127/example.xlsx
=INDIRECT(ADDRESS(MATCH([SEARCH_VALUE],Sheet2!$A:$A,0),[COLUMN],1,1,"Sheet2"))
[SEARCH_VALUE] is a Cell in your visible sheet containing the "Type" you want to lookup.
[COLUMN] is the column number that corresponds to the column you want to read from. (2 for Max Price and 3 for Warranty)
I didn't really understand your last comment, so without an example or a slightly more detailed explanation of what you need I cant help much more.

Resources