1、環境
伺服器 aix:編碼"iso-8859-1"
資料庫 informix:編碼"iso-8859-1"
頁面編碼:"iso-8859-1"
2、excel匯入中文亂碼問題
問題描述:
在excel檔案中,通過jxl框架匯入到資料庫中,為亂碼,顯示在頁面也為亂碼。
原因分析:
可能因為在excel檔案中編碼為gb2312,gbk或utf-8,而匯入到資料庫中為"iso-8859-1",中間沒有進行轉碼
導致存到資料庫中為亂碼,而頁面編碼也為"iso-8859-1",讀的就是資料庫的內容,也為亂碼。
解決辦法:
在excel資料匯入到資料庫之前先進行轉碼,如下
new string(shortname.getbytes("gb2312"),"iso-8859-1")
該構造方法在jdk api裡描述如下
string(byte bytes, string charsetname)
構造乙個新的 string,方法是使用指定的字符集解碼指定的位元組陣列。
備註:string(byte bytes, string charsetname) 方法在解決其他亂碼問題,同樣有效
Excel資料匯入到資料庫
使用表單檔案域 input type file 時,要讓form能夠傳遞檔案的話,必須要在form標籤中加入enctype multipart form data 後台 var contents oldrow 內容 tostring trim if contents.length 0 else if...
Excel資料匯入到oracle資料庫
1 將excel檔案儲存為 csv格式。2 新建乙個 ctl檔案,如下 load data infile d csv trailing nullcols id,name,age 3 開啟執行,輸入cmd,開啟命令提示符,輸入命令 sqlldr userid system test netservic...
Excel 匯入到資料庫,正解
最近做了個小的條碼,涉及要將excel中的資料讀取出來並以條碼的格式顯示 實驗目的 列印條碼標籤以供標識,掃瞄 實驗點 1.excel 的讀取 2.條碼圖形繪製 3.列印 點一 excel 匯入 string strconn provider microsoft.jet.oledb.4.0 data...