|
|
svirma |
(java)Проблема в кодировке при экспорте jTable в Excel  12.06.2011, 20:59 |
|
12/06/11 5
|
Здравствуйте. возникла проблема.. Решил добавить в программу функцию. которая позволяла бы таблицу JTable экспортировать в Excel. но при считывание русских слов в Excel(е) проблема в кодировке..Что можете подсказать. буду благодарен?
//----------------------------функция----------------------------------------
public void exportTable(JTable table, File file) throws IOException { TableModel model = table.getModel(); FileWriter out = new FileWriter(file); for(int i=0; i < model.getColumnCount(); i++) { System.setProperty("console.encoding", "Cp1251"); System.setProperty("file.encoding", "Cp1251"); out.write(model.getColumnName(i) + "\t"); } out.write("\n");
for(int i=0; i< model.getRowCount(); i++) { for(int j=0; j < model.getColumnCount(); j++) { System.setProperty("console.encoding", "Cp1251"); System.setProperty("file.encoding", "Cp1251"); out.write(model.getValueAt(i,j).toString()+"\t"); } out.write("\n"); }
out.close(); System.out.println("write out to: " + file); }
|
|
|
|
 |
|
Страница 1 из 1
|
[ 1 сообщение ] |
|
Модераторы: Karan, Toucan, PAV, maxal, Супермодераторы