Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to write in double order column after check the order id column?  RSS feed

 
Khresnario Surya
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to write on "Double Order" column = "It's Double Value" after check the "Order ID" column wheter it's duplicate value or not. i use apache poi. can someone help me?



here is the table

Customer IDOrder IDDouble Order
1004-1445880FU-002774  
1004-1445880FU-002774  
1004-1445880FU-002774  
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could have edited your previous thread...anyway.

If the table is ordered by the OrderId (or customer then order id) then you just need to remember the previous OrderId.
If the OrderId of the current row is the same then add the text to the DoubleOrder cell, if not then change the stored id to the current one.
 
Khresnario Surya
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to make it?
 
Paul Clapham
Sheriff
Posts: 22503
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An entry in that column is a duplicate if it is equal to any other entry in that column. So it follows that you must collect together all of the entries from the column before you can check whether any of them are duplicates. Why don't you start by doing that?
 
Khresnario Surya
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
already do that. and now I difficult to write the value to multiple specific cell. how to write to multiple specific cell? i look on google,all of that only write to 1 specific cell
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your post says that you want to write to the DoubleOrder cell of a particular row.
I'm not sure what other cell you are planning on writing into?
 
Paul Clapham
Sheriff
Posts: 22503
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Khresnario Surya wrote:how to write to multiple specific cell? i look on google,all of that only write to 1 specific cell


If you want to write to 3 cells, then you write to the first cell, then you write to the second cell, then you write to the third cell.

If you have a list of cells you want to write to, then you go through the list and for each cell in the list, you write to that cell.
 
Khresnario Surya
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already can check if the value is multiple. but now i difficult to write on selected column

 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is Cells are you storing on the 'col' Collection?

Is this the collection of Cells from a Row?

If so, then only the first Row has the headers, so that check on "Order ID" won't work for anything other than row 1.
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me just try and step through how I would do this (assuming I knew which columns held which data):


That's it.
 
Khresnario Surya
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's OrderID column. here the output on eclipse

0
Order ID
1
FU-002774
2
FU-002774
3
FU-002774
4
FU-002774
5
FU-002774
6

7

8
FU-002850
9
FU-002850
10
FU-002850
11
FU-002850
12
FU-002850

ROW no 1Double Order
ROW no 2Double Order
ROW no 3Double Order
ROW no 4Double Order
ROW no 5Double Order
ROW no 8Double Order
ROW no 9Double Order
ROW no 10Double Order
ROW no 11Double Order
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the issue now then?
 
Khresnario Surya
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to write it to "Double Order" columns. i look on google,all of forum show write by row one by one. how to make it from columns?
 
Campbell Ritchie
Marshal
Posts: 55751
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you got an Order class which encapsulates the order number and the ID? Can you write a toString method for that class which returns a single line?
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still don't see where you're stuck.

You have the Row (from the rowIterator).
You know which Cell you want (the third one).
So use row.getCell(2) (I think it's 0-based) to get the Cell representing the DoubleOrder column.
If the returned value is null then you can call row.createCell(2).

In both cases you will use the returned Cell to set the cell value.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!