Hi,
I am Saving data coming from database -> into a Datatable then importing into a
worksheet and saving it in CSV format.
I am actually saving the file in MapPath first and opening a dialog box and
having user save it whereever they want to.
the code looks like this:-
Protected Sub btn_Import_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_Import.Click
excelEngine = New ExcelEngine()
appl = excelEngine.Excel
workbook = appl.Workbooks.Create(3)
Dim strpath1 As String = Server.MapPath("Import")
Comments:-GetDataToCSVFile()
Method call is very simple in selecting 4 columns from a sql table and out of it 3 are varchar columns and one is int-:Comments
Dim mycsvdatatable As DataTable = GetDataToCSVFile()
sheet = workbook.Worksheets(1)
sheet.ImportDataTable(mycsvdatatable, False, 1, 1)
sheet.SaveAs(strpath1 & "\" & "Sample.csv", ",", Encoding.ASCII)
Comments:-Opens a dialog box to
save-:Comments
Response.Redirect("~\Import\" & "Sample.csv", False)
End Sub
Attached CSV file has Text/varchar columns (Columns B,C,D in attached file) in Quotes.As i mentioned above 3 columns they are enclosed in Double Quotes in CSV file. May i know Why? Is there any way to remove them via Sync's save as() method
In another example for CSV file i got from your forums:-
I see the format to save the file is different- there is no encoding parameter?
workbook.SaveAs(Server.MapPath("sample.csv"),"/t");
Are the Double quotes due to saving format as Encoding.ASCII?
Regards,
Vidya
Sample_50df277f.zip