- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 jexcelapi for android .
我写字符串“Hello jExcelAPI!”,但是当我读的时候我看到了中文符号。
我该如何解决?
提前致谢。
附言也许有帮助:我不知道需要在 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);
}
}
最佳答案
这是“WorkbookSettings”类的文档:http://jexcelapi.sourceforge.net/resources/javadocs/2_6_10/docs/jxl/WorkbookSettings.html似乎方法“setCharacterSet”仅用于读取(导入)电子表格,如果有帮助则不导出。至于中文字符,我认为它们是由于您的语言环境而显示的。我会使用这些常量通过正确的语言和国家/地区构造函数参数正确实例化您的 Locale 对象:http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Locale.html
关于android - 在 jexcelapi 中编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8424607/
在 Excel 中,我可以在一个单元格中拥有多种文本样式。有没有办法使用 JExcelApi 创建这样的文件?到目前为止我没有看到任何东西:setCellFormat 是 WritableCell 上
我一直在使用 JExcelAPI 在 Java 中编写和读取 Excel 文件。当我读取由 JExcelAPI 编写的文件时,它工作正常,但如果我使用 OpenOffice 等其他程序修改 .xls
如何使用第三方库? 我已经下载了它,但不确定如何处理它,我是否将它放在我的 Eclipse 项目文件夹等中? 我确实在网站上查看过,但没有结果 谢谢 最佳答案 您需要在项目类路径中设置 jar。导入后
我想知道是否可以使用 Java JExcepAPI 创建一个包含文本“Red Rose Blue Sky”的 Excel 文件单元格(标签),其中“Rose”显示为红色,“Blue”显示为 - 你猜怎
我可以使用以下命令找到 Excel 文档中的行数sheet.getRows();但是我的 Excel 文件中的行长度不同,我怎样才能只获取 1 列中的行数。我发现了 getting rows in f
我为 jExcelApi 类创建了一个包装器,以便轻松地将对象列表导出到 Excel。为了最大限度地减少对象创建,单元格格式被创建为静态字段,并在连续的导出调用中重复使用。但我对日期格式有问题 - 第
我正在使用 JExcelApi 生成 XLS 文件。来自 jxl.format.Colour ,我了解了如何获取“标准 Excel 调色板”中的任何颜色,但没有了解如何创建新颜色(例如,给定其 RGB
首先我要说的是,我对 Java 和这个网站都很陌生。我现在已经读了一两本书,从那时起我就一直在寻找小项目来让自己开心。我尝试对此进行研究,但无法找到我需要的信息。话虽如此,这是我的第一个问题,所以如果
我需要检测单元格内的文本是否被删除。我正在使用这个: Cell cc = sheet.getCell("B1"); CellFormat format = cc.getCellFormat(); Sy
我有一个 Excel 工作表,其中包含一些非英语字符,当我尝试通过 获取内容时 sheet.getColumn(column)[row].getContents() 它返回带有替换字符\uFFFD 的
我使用 jexcelapi for android . 我写字符串“Hello jExcelAPI!”,但是当我读的时候我看到了中文符号。 我该如何解决? 提前致谢。 附言也许有帮助:我不知道需要在
这是我的第一篇文章,请多多包涵。我正在尝试做一些简单的事情:查看包含公式的电子表格单元格的值。似乎什么都不起作用,我得到的不是正确答案(579),而是“4”。 (输出如下)。该程序创建一个简单的电子表
当我添加 JExcelAPI 时 http://jexcelapi.sourceforge.net/到类路径并运行我的应用程序,我得到:编写输出时遇到问题:不应该发生[2009-07-16 14:32
我有一个成功导出到 Excel 的 Jasper 报告,但是所有数字列(当前为 java.math.BigDecimal 类型)在 Excel 中显示为“常规”类型。这使得无法对列进行数字运算(例如添
我正在用 JExcelApi 编写电子表格. 我有两个要应用货币格式的单元格。通过阅读 API,我发现了 jxl.write.NumberFormat,它似乎可以满足我的要求。在我的应用程序中,我写了
我安装了java并设置了路径,运行成功。现在我需要的是如何使用 jexcelapi。我下载了 jexcel api 并将其解压缩。我不知道在哪里放置提取的文件,也不知道如何为 jexcel 文件设置
我正在使用 JExcelApi 生成 xls 文件。现在我需要的是锁定标题,因为我有超过 300 行。 每当我滚动时,我都需要显示标题。谁能帮我解决这个问题。我浏览了很多网站,但没有找到解决方案。 O
在尝试使用 jExcelAPI 读取 xls 文件时,我发现该库在 stderr 中转储了大量信息,有时这些信息不相关。例如,此代码片段会导致大量“警告”转储到 stderr 流上: Work
我尝试使用 JExcelAPI (v. 2.6.3) 在 Java 应用程序中生成一些 Excel 工作表,但无法正确生成日期单元格。例如,对于代码: WritableWorkbook workboo
我正在使用 Java 编写 MS Excel 文件,以及如何设置“跟踪更改”标志,以便我可以看到人们稍后进行修改的位置。如何在 jexcelapi 或 Apache HSSF 中设置此标志? 最佳答案
我是一名优秀的程序员,十分优秀!