Hello,
I am evaluating the XLS component and i want to be able to open an excel file and convert it to a text file. I noticed in your sample that i downloaded that i can save a workbook to a stream. So I put together my own sample code that opens my excel file and writes it out to a file. When i run this, you seem to be overwriting my xls file with your copyright information because this is a trial version. My question is: Does the component support this?
Thanks for your help.
Dim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
Dim sFile As String
'Save an excel workbook to stream
Dim fileStream As FileStream = New FileStream("An_Inventory_Example.xls", FileMode.Open)
workbook.SaveToStream(fileStream)
Dim bytes() As Byte = New Byte((fileStream.Length) - 1) {}
Dim numBytesToRead As Integer = CType(fileStream.Length, Integer)
Dim numBytesRead As Integer = 0
Dim objWriter As New System.IO.StreamWriter("An_Inventory_Example.prn")
objWriter.Write(bytes)
While (numBytesToRead > 0)
' Read may return anything from 0 to numBytesToRead.
Dim n As Integer = fileStream.Read(bytes, numBytesRead, _
numBytesToRead)
' Break when the end of the file is reached.
If (n = 0) Then
Exit While
End If
numBytesRead = (numBytesRead + n)
numBytesToRead = (numBytesToRead - n)
objWriter.Write(bytes)
End While
numBytesToRead = bytes.Length
objWriter.Close()