Hello Group, For days I have been struggling with trying to write an app that takes a users uploaded file(xls) and converts it over to csv so I can parse it. I tried using the microsoft interpub dll's but we can't have the Office Package on the production server.
The next method I tried is using Microsoft.ACE.OLEDB.12.0. It seems to be able to find the file Book.xls but it can never find the sheet to query from. I left the Sheet name alone to stay as Sheet1. Everytime I run the page it says "System.Data.OleDb.OleDbException: The Microsoft Office Access database engine could not find the object 'Sheet1$'. " The error occurs on the last line which is "da.Fill(dt)". Below is relavant code. Can someone please help? Thank you... Dim sourceFile As String, worksheetName As String, targetFile As String sourceFile = System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName) worksheetName = "Sheet1" targetFile = System.Configuration.ConfigurationManager.AppSettings("XLSPath") & "myWorkbookCSV.csv" convertExcelToCSV(sourceFile, worksheetName, targetFile) ....... end sub.... Private Sub convertExcelToCSV(ByVal sourceFile As String, ByVal worksheetName As String, ByVal targetFile As String) Dim strConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & sourceFile & ";Extended Properties=""Excel 12.0""" Dim conn As OleDbConnection = Nothing Dim wrtr As StreamWriter = Nothing Dim cmd As OleDbCommand = Nothing Dim da As OleDbDataAdapter = Nothing Try conn = New OleDbConnection(strConn) conn.Open() cmd = New OleDbCommand("SELECT * FROM [Sheet1$]", conn) cmd.CommandType = CommandType.Text wrtr = New StreamWriter(targetFile) da = New OleDbDataAdapter(cmd) Dim dt As New DataTable() da.Fill(dt) -- You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to dotnetdevelopment@googlegroups.com To unsubscribe from this group, send email to dotnetdevelopment+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en or visit the group website at http://megasolutions.net