A lot of people must met the question like File Export. There are some solutions to do that thing.
First, POI is an easy-to-use framework to operate the office document besides Excel file.
Second, jexcelapi is a very good tool to export the Excel file.
All two open source software are extremely easy-to-use and there are very detailed document and examples to refer to.
Today, I'm gonna express one thing: there's requirement like following image.
result
The condition is that there are two group of data. one is (1,1,1,1,1,1), another is (2,2,2,2,2,2).
The question is how to do to show the result like that image?
import java.util.ArrayList;
import java.util.List;
public class Example {
public static void main(String[] args) {
String[] strArr = {"1", "2"};
int count = 0;
List<String> strList = createData();
for (String par: strArr) {
while(strList.size() > 0) {
String str = strList.get(0);
if (par.equals(str)) {
if (count == 0) {
System.out.println(str);
} else {
System.out.println(str+":grey");
}
strList.remove(str);
count ++;
} else {
count = 0;
break;
}
}
}
}
public static List<String> createData() {
List<String> arrayList = new ArrayList<String>();
arrayList.add("1");
arrayList.add("1");
arrayList.add("1");
arrayList.add("1");
arrayList.add("1");
arrayList.add("1");
arrayList.add("2");
arrayList.add("2");
arrayList.add("2");
arrayList.add("2");
arrayList.add("2");
arrayList.add("2");
return arrayList;
}
}
Notice:
- the consequence of
strArr
must be equel to thearrayList
.