跳到主要內容

發表文章

[VB.net] 整合excel的用法

1.在參考中加入excel COM元件   Microsoft Excel 11.0 object library 或   Microsoft Excel 12.0 object library 如果加入之後 有錯誤 可能是缺少 Office PIA 可以到網路上下載 2.使用code Dim excel As New Microsoft.Office.Interop.Excel.ApplicationClass Dim wBook As Microsoft.Office.Interop.Excel.Workbook Dim wSheet As Microsoft.Office.Interop.Excel.Worksheet wBook = excel.Workbooks.Add() wSheet = wBook.ActiveSheet() /*對內容處理*/ excel.Cells(1, 1) = "123" wSheet.Columns.AutoFit() Dim excelFileName As String = "F:\MyExcel.xls" wBook.SaveAs(excelFileName) wBook.Close() excel.Quit() excel = Nothing

[VB.net]特殊控制字元

ControlChars 模組成員 CrLf vbCrLf Chr( 13 ) + Chr( 10 ) 歸位/換行字元 (Carriage Return/Linefeed) 組合。 Cr vbCr Chr( 13 ) 歸位字元。 Lf vbLf Chr( 10 ) 換行字元。 NewLine vbNewLine Chr( 13 ) + Chr( 10 ) 新行字元 (Newline Character)。 NullChar vbNullChar Chr( 0 ) 具有 0 值的字元。 N/A vbNullString 具有 0 值的字串 與長度為零的字串 ("") 不同;用來呼叫外部程序。 N/A vbObjectError -2147221504 錯誤代碼。使用者定義錯誤代碼應大於這個值。例如: Err.Raise(Number) = vbObjectError + 1000 Tab vbTab Chr( 9 ) 定位字元。 Back vbBack Chr( 8 ) 退格鍵 (Backspace)。 FormFeed vbFormFeed Chr( 12 ) 在 Microsoft Windows 中的作用不大。 VerticalTab vbVerticalTab Chr( 11 ) 在 Microsoft Windows 中的作用不大。 Quote N/A Chr( 34 ) 用來封入值的引號字元 (" 或 ')。

[Data Mining]SVM -SVM, Support Vector Machine

SVM, Support Vector Machine, is something that has similar roots with neural networks. But recently it has been widely used in Classification . That means, if I have some sets of things classified (But you know nothing about HOW I CLASSIFIED THEM, or say you don't know the rules used for classification), when a new data comes, SVM can PREDICT which set it should belong to. Reference: SVMs piaip's Using (lib)SVM Tutorial Dr CJLin Kernel-Machines.Org

[.Net]__doPostBack用法

__doPostBack(__EVENTTARGET,__EVENTARGUMENT) _doPostBack是通過__EVENTTARGET,__EVENTARGUMENT兩個隱藏控制項向服務端發送控制要求的 __EVENTTARGET為要呼叫的控制項名稱,如果要呼叫的控制項是子控制項,用''$'或':'分割父控制項:子控制項, __EVENTARGUMENT 是調用事件時的參數,通常為空 Control如果含有":" ,需要預先替替換"$" 但是在我們呼叫__doPostBack函數時,有些時候呼叫這個函數會出現"物件不存在"的錯誤? 那是因為Html裏面沒有__doPostBack函數物件,一般在拖放那些有自動回傳功能的控制項時,當把他的autoPostback屬性設為True, 在運行的時候系統會自動添加__doPostback函數體,當然最直接的辦法就是添加一個LinkButton然後把其Text屬性設為空,切記不要設 Visible屬性,因為如果Visible=false,在翻譯成Html時,直接就忽略LinkButton的存在了。 Ref: __doPostBack用法感悟收藏

[.Net]JPG品質調整

Imports System.Drawing.Imaging Sub SaveJPG()  Dim Image as Bitmap = New Bitmap(OrigianalImageFile)   '設定壓縮品質90檔案大小約是100的一半 但是畫質還是很不錯  Dim quality As Integer = 90  Dim qualityParam As New EncoderParameter(Encoder.Quality, quality)  '取得編碼格式   Dim jgpEncoder As ImageCodecInfo = GetEncoder(ImageFormat.Jpeg)  Dim encoderParams As New EncoderParameters(1)  encoderParams.Param(0) = qualityParam  Image.Save(NewImageFile, jgpEncoder, encoderParams) End Sub '取得編碼格式的副程式 Private Function GetEncoder(ByVal format As ImageFormat) As ImageCodecInfo  Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageDecoders()  Dim codec As ImageCodecInfo   For Each codec In codecs    If codec.FormatID = format.Guid Then     Return codec    End If   Next codec  Return Nothing End Function 參考資料: MSDN

[ASP.Net] 分頁型Excel匯出

用產生xml的方式 gene 標頭用 xmlTextWriter 產生Excel 會在Excel 2003無法開啟 所以改用response.write產生 Response.Charset = "UTF8" Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8") Response.AddHeader("content-disposition", "attachment; filename=" & filename & ".xls") Response.ContentType = "application/vnd.ms-excel" Response.Write("<?xml version='1.0'?>") Response.Write("<?mso-application progid='Excel.Sheet() '?>") Response.Write("<Workbook xmlns='urn:schemas-microsoft-com:office:spreadsheet'") Response.Write(" xmlns:o='urn:schemas-microsoft-com:office:office'") Response.Write(" xmlns:x='urn:schemas-microsoft-com:office:excel'") Response.Write(" xmlns:ss='urn:schemas-microsoft-com:office:spreadsheet'") Response.Write(" xmlns:html='http://www.w3.org/TR/REC-html40'>") 每個Sheet開頭 Respon...