2014年1月14日 星期二

sqlserver2008匯出資料 insert指令

產生指令碼
點下一步

點選要匯出的資料表

點選"進階"->選僅限資料

選擇要匯出到哪裡

開始匯出

匯出完成,可以insert到其他DB



2012年5月29日 星期二

神奇的parseInt("08")

在寫JS的時候
一直測試文字轉數字
剛好測到08 與09要轉數字
奇怪跑出來的結果都是0
真的很納悶
我以為我程式有bug
就去google了一下發現原來是位元字的問題
不是我程式的BUG..冏rz
轉載日期2008/6/3
http://audi.tw/Blog/JavaScript/javascript.parseInt.asp

2011年10月5日 星期三

HTC sensation 擷取手機畫面


按下手機上方電源鍵+主畫面鍵就可以擷取目前畫面
再到相簿中就可以看到擷取的畫面摟....

2011年5月5日 星期四

jsp匯出excel

1.下載jxl套件

2. jsp中

try {

String original_filename = "fileToOutput.xls";
String sRealPath = (String) original_filename;
//產生要存的excel
File file = new File(sRealPath);
//產生一檔案WritableWorkbook讓程式匯出
WritableWorkbook writableWorkBook = Workbook.createWorkbook(file);
//在檔案中開啟一新的sheet
WritableSheet writableSheet = writableWorkBook.createSheet("我是第一張sheet", 1);
//WritableSheet writableSheet2 = writableWorkBook.createSheet("我是第二張sheet", 2);
//設定寫入儲存格的字型大小
WritableFont chFont12w = new WritableFont(WritableFont.createFont("Times New Roman"), 12);
WritableCellFormat writableCellFormat = new WritableCellFormat(chFont12w);

//label中的(0,0)代表excel中的(A,0)
//label中的(1,0)代表excel中的(B,0)
//label中的(1,1)代表excel中的(B,1),以此類推
Label deptLabel = new Label(0, 0, "印出字串",writableCellFormat);
writableSheet.addCell(deptLabel);

//寫入EXCEL檔案
writableWorkBook.write();
//關閉檔案
writableWorkBook.close();


} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

2011年4月1日 星期五

httpclient file中文檔名上傳

要先認證(我用NTLM)

NTCredentials creds = new NTCredentials("帳", "密", "", "網域");
httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);


HttpPost httppost = new HttpPost("上傳目標位置");
httpclient.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET,"UTF-8");
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,HttpVersion.HTTP_1_1);
FileBody bin = new FileBody(new File(sourcePath),"","UTF-8");
StringBody title = new StringBody(fileName,Charset.forName("UTF-8"));

MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE,null,Charset.forName("UTF-8"));

reqEntity.addPart("file", bin);
reqEntity.addPart("fileTitle", title);

httppost.setEntity(reqEntity);

HttpResponse response = httpclient.execute(httppost);
EntityUtils.consume(resEntity);
try {
httpclient.getConnectionManager().shutdown();
} catch (Exception ee) {ee.printStackTrace(); }


***接收***
使用org.apache.commons.fileupload.FileItem 套件
怎麼接收檔案就不描述了
字串接收

if ("fileTitle".equals(item.getFieldName())) {
fileTitle = new String(item.getString().getBytes("ISO-8859-1"), "UTF-8");
}

檔案接收
可接收檔名

originalFileName = item.getName();
System.out.println("originalFileName:"+originalFileName);


有任何問題請留言或mail可以討論

2011年3月23日 星期三