ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Convert Excel file into CSV with Microsoft Office Interop library using C# and VB.Net in ASP.Net<p>Hi <a class="username" rel="amar"> amar</a>,</p> <p>Refer the below sample function. For this i have used Microsoft.Office.Interop.Excel library.</p> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">using Excel = Microsoft.Office.Interop.Excel; public void ExcelToCSV(string sourceFile,string destinationFile) { Type officeType = Type.GetTypeFromProgID(&#34;Excel.Application&#34;); if (officeType == null) { ClientScript.RegisterClientScriptBlock(this.GetType(), &#34;&#34;, &#34;alert(&#39;Excel is not installed in the machine&#39;)&#34;, true); } else { Excel.Application app = new Excel.Application(); app.DisplayAlerts = false; // Open Excel Workbook for conversion. Excel.Workbook excelWorkbook = app.Workbooks.Open(sourceFile); // Save file as CSV file. excelWorkbook.SaveAs(destinationFile, Excel.XlFileFormat.xlCSV); // Close the Workbook. excelWorkbook.Close(); // Quit Excel Application. app.Quit(); } }</pre> <p><span style="text-decoration: underline;">VB.Net</span></p> <pre class="brush: vb">Imports Excel = Microsoft.Office.Interop.Excel Public Sub ExcelToCSV(sourceFile As String, destinationFile As String) Dim officeType As Type = Type.GetTypeFromProgID(&#34;Excel.Application&#34;) If officeType Is Nothing Then ClientScript.RegisterClientScriptBlock(Me.[GetType](), &#34;&#34;, &#34;alert(&#39;Excel is not installed&#39;)&#34;, True) Else Dim app As New Excel.Application() app.DisplayAlerts = False &#39; Open Excel Workbook for conversion. Dim excelWorkbook As Excel.Workbook = app.Workbooks.Open(sourceFile) &#39; Save file as CSV file. excelWorkbook.SaveAs(destinationFile, Excel.XlFileFormat.xlCSV) &#39; Close the Workbook. excelWorkbook.Close() &#39; Quit Excel Application. app.Quit() End If End Sub</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/267072/Convert-Excel-file-into-CSV-with-Microsoft-Office-Interop-library-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/267072/Convert-Excel-file-into-CSV-with-Microsoft-Office-Interop-library-using-C-and-VBNet-in-ASPNet/Tue, 17 Oct 2017 23:58:44 GMT