我写了字符串“Hello jExcelAPI!”,但是当我阅读时,我看到了中文符号。
我该如何解决?
提前致谢。
PS也许有帮助:我不知道 ws.setCharacterSet(cs);
package ru.elvigl.hello;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.read.biff.BiffException;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class HellojExcelAPIActivity extends Activity {
final File file = new File("/sdcard/Folder/File.xls");
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void btnExport_Click(View v) throws IOException, RowsExceededException, WriteException {
WorkbookSettings ws = new WorkbookSettings();
//ws.setCharacterSet(cs);
ws.setEncoding("Cp1251");
ws.setExcelDisplayLanguage("RU");
ws.setExcelRegionalSettings("RU");
ws.setLocale(new Locale("ru", "RU"));
WritableWorkbook workbook = Workbook.createWorkbook(file, ws);
WritableSheet sheet = workbook.createSheet("First Sheet", 0);
Label label = new Label(0, 0, "Hello jExcelAPI!");
sheet.addCell(label);
workbook.write();
workbook.close();
}
public void btnImport_Click(View v) throws BiffException, IOException {
WorkbookSettings ws = new WorkbookSettings();
//ws.setCharacterSet(cs);
ws.setEncoding("Cp1251");
ws.setExcelDisplayLanguage("RU");
ws.setExcelRegionalSettings("RU");
ws.setLocale(new Locale("ru", "RU"));
Workbook workbook = Workbook.getWorkbook(file, ws);
Sheet sheet = workbook.getSheet(0);
Cell a1 = sheet.getCell(0,0);
String str = a1.getContents();
TextView tv = (TextView) findViewById(R.id.tvCellValue);
tv.setText(str);
}
}