DTS 패키지를 기반으로 한보고 시스템을 자동화하는 응용 프로그램이 있습니다. 웹 기반 앱은 현재 출력 xls 파일을 네트워크의 다른 서버에 쓰고 있습니다. 웹 사이트를 닫은 후에도 서버 인스턴스에서 Excel 인스턴스가 실행 중임을 알게되었습니다. xls 파일 대신 csv 파일을 출력하는 내 기존 루틴을 변경하거나 네트워크로 연결된 컴퓨터에서 EXCEL.exe 프로세스를 종료 할 수 있습니다. 도와주세요!xls을 csv로 변환하거나 EXCEL.exe 프로세스를 죽입니다.
편집 : 여기에이 파일이 그 사진은 기본적으로 행이 분리되어 보여줍니다 너무 작은하지만 열이없는 경우 CSV
로 저장하기 전 파일 확장자를 변경하면 모습입니다. 쉼표가 열을 구분하는 데 있어야 할 곳에 물음표 대신 작은 상자가있다
여기이다 가깝게, 당신은 예에서 엑셀을 사용하지
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
기타 Chris가 옳습니다. 나는 ascii 뇌 손상이 있었다. – MNGwinn
감사합니다. 그게 다른 사람이 나 한테도 말한거야. 하지만 파일 확장명을 CSV로 변경하면 파일이 모두 꺼집니다. 위의 편집을 참조하십시오. – JDV590
@ JDV590 - 탭 문자를 표시 할 수없는 문자로 표시하는 Excel (또는 파일을보고있는 프로그램) 일 가능성이 높습니다. "텍스트 가져 오기 마법사"를 사용하여 Excel에서 파일을 열면 "탭"을 선택해야하는 구분 기호가 무엇인지 묻습니다. –