"excel to json converter in java" Code Answer


i too faced this type of scenario. you just create a class with the fields which you having in the second sheet. for ex:

public class somename{

private string abc;
private string xyz;
// getters and setters

in your pojo class define an array

private somename some[];

goto exceltojson converter class.try to create hash map and fetch the details which u need in that sheet. that's it...

    public static map getimgs(hssfworkbook wb) {

   map hm1 = new hashmap<string, arraylist<somename>>();
    hssfsheet sheet = wb.getsheetat(2);
    iterator<row> iterator= sheet.iterator();
    arraylist<somename> al = new arraylist<somename>();
    while (iterator.hasnext()) {
        row row = iterator.next();

        string sno = new dataformatter().formatcellvalue(row.getcell(0));

        if (hm1.get(sno) == null) {
            hm1.put(sno, new arraylist());

        string some= new dataformatter().formatcellvalue(row

        somename img1 = new somename(some);

        arraylist r = (arraylist) hm1.get(sno);

    return hm1;

then add this uploadxls,

  arraylist<somename> al = (arraylist<somename>) hm1.get(id_prod);
                        somename[] ar = new images[al.size()];


may be this will help you.

By subhaze on June 2 2022

Answers related to “excel to json converter in java”

Only authorized users can answer the Search term. Please sign in first, or register a free account.