无法使用JExcel Api从Excel文件正确读取西班牙语字符

时间:2019-06-24 17:05:58

标签: java android character-encoding jexcelapi

西班牙字符无法从Excel文件中正确读取,但我尝试对其进行编码,但无法正常工作。我从Excel文件复制了相同的字符串并将其放入字符串中,就可以正常工作

我尝试使用字符集对它进行编码,但是它不起作用,我也尝试了不同的方法,但是没有一个方法起作用。

 try{
        //  Toast.makeText(MainActivity.this,"inside",Toast.LENGTH_SHORT).show();

        InputStream is=getResources().openRawResource(R.raw.test);
        Workbook wb =Workbook.getWorkbook(is);
        Sheet s=wb.getSheet(0);
        int row =s.getRows();
        int col=s.getColumns();
        String xx="";
        for(int i=0;i<row;i++)
        {
            for (int c=0;c<col;c++)
            {
                Cell z=s.getCell(c,i);



                String text = z.getContents().toString();
                byte[] byteText = text.getBytes(Charset.forName("UTF-8"));
                String originalString= new String(byteText , "UTF-8");

                if (c == 0) {
                    xx = xx + " " + originalString;
                }
                if (c == 1) {
                    xx = xx + " " + originalString;

                }
                if (c == 2) {

                    xx = xx + " " + originalString;


                }

            }




            //System.out.println(decodedText);
            t.setText(xx);
           // Toast.makeText(getApplicationContext(),xx,Toast.LENGTH_LONG).show();
            xx=xx+"\n";

        }

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

我需要从excel文件正确编码

0 个答案:

没有答案