1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
Imports Microsoft.Office.Interop.Excel Public Class clsxls ' Dim bucd As String Dim filepass As String Dim hyouji As Boolean Dim xlApp As New Application() Dim sheet As Object Dim nendo As String Dim id As Integer = 0 Public Sub New(filepass1 As Object) filepass = mo_ck.str(filepass1) End Sub ''' <summary> ''' ''' </summary> ''' <returns></returns> Public Function funyomikomi() As String Dim sb As New StringBuilder sb.Clear() Dim t As String = ControlChars.Tab ' Dim strkey As String = "" Dim fileName As String = filepass Dim kin As Integer = 0 Dim keihi As Integer = 0 Dim keihi_meisyou As String = "" id = 0 Try If xlApp IsNot Nothing Then xlApp.Visible = hyouji xlApp.Workbooks.Open(fileName) Dim icount As Integer = xlApp.ActiveWorkbook.Worksheets.Count For index = 1 To icount ’===読み込む処理 sb.Append("物件名" & ControlChars.Tab & sss & ControlChars.Tab) Next End If Catch ex As Exception sb.Append(ControlChars.CrLf & " (ERR!!) " & ex.Message.ToString()) Finally xlApp.ActiveWorkbook.Close() xlApp.Quit() End Try Return sb.ToString End Function ''' <summary> ''' ''' </summary> ''' <param name="i">シート数</param> ''' <param name="sagasukoumoku">捜す項目</param> ''' <param name="sagasuHani">シート内で探す範囲</param> ''' <param name="mojisu">文字数</param> ''' <returns></returns> Private Function funsyoudsaiyomikomi(i As Integer, sagasukoumoku As String, sagasuHani As String, mojisu As Integer) As String Dim t As String = ControlChars.Tab Dim ss As New StringBuilder CType(xlApp.ActiveWorkbook.Sheets(i), Worksheet).Select() sheet = xlApp.ActiveSheet Dim aRange As Range = xlApp.Range(sagasuHani) Dim bRange As Range bRange = aRange.Find(sagasukoumoku, LookAt:=XlLookAt.xlPart) If bRange Is Nothing Then '==ない Return "notFind (" & sheet.name & ")" End If Dim s As String = "" For ii As Integer = bRange.Column To bRange.Column + 10 s &= sheet.cells(bRange.Row, ii).value Next s = s.Replace(sagasukoumoku, "") If s.Length >= mojisu Then s = s.Substring(mojisu) End If Return (s.ToString) End Function End Class |