Tuesday 15 July 2014

Java - Apache POI - It's impossible to fill rows and cells with loops in this pattern? (Excel) -


Recently I opened this topic:

I hope It was that another structure developed that it would solve the problem, and the problem became more clear.

With that pattern in mind:

  hashishi 1 | Hashki 2 Hashki 3 Hashky4 value1-1 | Price 2-1 | Value3-1 | Value4-1 values ​​1-2 Value 2-2 Value 3-2 Price 4-2 Price 1-3 | Price 2-3 Value3-3 | Value4-3 values1-4 Value 2-4. Value 3-4 Value 4-4 values ​​1-5. Price 2-5 | Value 3-5 | Value4-5   

Here's the new code:

  line of line = worksheet. Cutter (4); Row value rows = null; Int nail = 2; Int firstIndex = 0; Int secondIndex = -2; Int row = 5; ArrayList & LT; String & gt; Keyre = new arrivate (); ArrayList & LT; String & gt; InnerValueArray; ArrayList & LT; ArrayList & LT; String & gt; & Gt; External Valuerre = new Array list & lieutenant; Arrest & lt; String & gt; & Gt; (); (Map. Entry & lt; string; Array list & lt; string & gt; E: matrix: dictate ()) {keyArray.add (e.getKey ()); InnerValueArray = New ArrayList (); For (string s: e.getValue ()) {innerValueArray.add (s); } External Valueray.ed (InvervilAire); } (String s: keyre) {keyCell + = 2; KeyRow.createCell (keyCell) .setCellValue (keyArray.get (firstIndex ++)); } (Arrayist & lt; string & gt; AS: External Value Array) {Second Index = = 2; For (string s: AS) {if ((line - 5) & outerValueArray.size ()) {row ++; } ValueRow = worksheet.createRow (line); ValueRow.createCell (secondIndex) .setCellValue (s); }}   

In the second topic, the problematic variable is "keycale", and in this one, this is the second index. The only way to put it in the right place is through a single variable that is used for the keys, but it makes it possible to fill only one column, erasing the contents of others. The problem is very similar to the other subject. All options take on this, and I want to assume in the same line.

The question is: Is it impossible to fill sheet and achieve excellence in this method? Because it is definitely impossible to update the variable in the internal loop and to keep the desired pattern, how can I make this pattern with loops?

OBS: This increases my software by 2, it does not matter

I'm not sure that I really understand your question, but look at it creates a worksheet with the pattern you described:

  import Java.io. *; Import java.util. *; Import org.apache.poi.hssf.usermodel.HSSFWorkbook; Import org.apache.poi.ss.usermodel. *; Public class PoiPattern {@SuppressWarnings ({"raw type", "uncheck"}) Public static zero chief throws exception (string [] args {mapp & lt; String, array list & lt; String & gt; & Gt; Matrix = new hashmap & lt; String, Arlist & lt; String & gt; & Gt; (); For (int i = 1; i    

No comments:

Post a Comment