DTSパッケージにもとづいたレポートシステムを自動化するアプリケーションがあります。 Webベースのアプリケーションは現在、出力xlsファイルをネットワーク上の別のサーバーに書き込みます。私は、Webサイトが閉じられた後でさえ、書かれているサーバー上で実行されているExcelのインスタンスが残っていることを発見しています。私は、xlsファイルではなくcsvファイルを出力するための私のルーチンを変更することも、ネットワーク接続されたマシン間でEXCEL.exeプロセスを強制終了することもできます。助けてください!xlsをcsvに変換するか、EXCEL.exeプロセスを終了させます
編集:ここでは、私はその絵が、それは基本的に行が分離している示していますが、列はありません小さすぎる場合、CSV
として保存するファイルの拡張子を変更した場合、ファイルは次のようになります。カンマが列を分離することであるべきところに疑問符を持つ代わりに、小さなボックスがあり
ここあるなどの近くに、あなたは一例でExcelを使用していない
Public Sub DisplayandConvertToXLS()
Dim i As Integer
Dim ds As New DataSet
Dim da As SqlDataAdapter
Dim objFileStream As FileStream
Dim objStreamWriter As StreamWriter
Dim fs As Object, myFile As Object
Dim cnn As SqlConnection = New SqlConnection("DataSource=dpsdb;InitialCatalog=productionservicereminder;User Id=id;Password=pass;")
Dim strLine, filePath, fileExcel As String
'Create a file name.
fileExcel = FileNameTxt.Text & ".xls"
'Set a virtual folder to save the file.
'Make sure that you change the application name to match your folder.
filePath = "\\10.1.2.4\SRS Shortcuts\Export\SQL Output\CSV Reports\"
fileName = filePath & FolderNameTXT.Text & "/" & fileExcel
'Use FileStream to create the .xls file.
objFileStream = New FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write)
objStreamWriter = New StreamWriter(objFileStream)
'Use a DataReader to connect to the database.
cnn.Open()
Dim sql3 As String = DisplayQTXT.Text
Dim cmd As SqlCommand = New SqlCommand(sql3, cnn)
cmd.Parameters.Add(New SqlParameter("@ProgramGroupID", PgidTXT.Text))
Dim drr As SqlDataReader
drr = cmd.ExecuteReader()
'Enumerate the field names and records that are used to build the file.
For i = 0 To drr.FieldCount - 1
strLine = strLine & drr.GetName(i).ToString & Chr(9)
Next
'Write the field name information to file.
objStreamWriter.WriteLine(strLine)
'Reinitialize the string for data.
strLine = ""
'Enumerate the database that is used to populate the file.
While drr.Read()
For i = 0 To drr.FieldCount - 1
strLine = strLine & drr.GetValue(i) & Chr(9)
Next
objStreamWriter.WriteLine(strLine)
strLine = ""
End While
'Clean up.
drr.Close()
cnn.Close()
ds.Clear()
objStreamWriter.Close()
objFileStream.Close()
objStreamWriter.Dispose()
objFileStream.Dispose()
End Sub
その他クリスが正しいです。私はascii脳の故障があった。 – MNGwinn
ありがとうございます。誰かが私にも同様に言ったものです。しかし、私がファイル拡張子をcsvに変更すると、私のファイルはすべてオフになります。上記の編集を参照してください。 – JDV590
@ JDV590 - これは、タブ文字を表示できない文字として表示する可能性が高いExcel(またはファイルを表示しているプログラム)です。 「テキストインポートウィザード」を使用してExcelでファイルを開くと、区切り文字が「Tab」を選択する必要があるかどうかが尋ねられます。 –