Excel to csv without excel

Need to convert a .xls or .xlsx to a .csv without the use of Excel in an C#/ASP.net web app. The application is currently using the NPOI.dll for some functionality but I do not see any info on the codeplex wiki for NPOI for that particular functionality. Does anyone have any suggestions?

Thanks

asked Sep 27, 2011 at 17:53

Tim's user avatar

1

There are libraries ( Excel Data Reader, for eg) that let you read excel. Once you are able to read data, writing to csv should be simple.

answered Sep 27, 2011 at 18:04

Bala R's user avatar

Bala RBala R

107k23 gold badges197 silver badges209 bronze badges

ADODB.NET can be used to treat the Excel files as datasource.

//string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;";
string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 12.0;";

ConnectionString = string.Format(ConnectionString, @"FullPathToExcelFile");

OleDbConnection conn = new OleDbConnection(ConnectionString);
conn.Open();

OleDbCommand cmdSelect = new OleDbCommand("SELECT * FROM [Sheet1$]", conn);
OleDbDataAdapter oleDBAdapter = new OleDbDataAdapter();
oleDBAdapter.SelectCommand = cmdSelect;

DataSet myDataset = new DataSet();
oleDBAdapter.Fill(myDataset);
conn.Close(); 

// Do whatever with data in myDataset including export to csv...

answered Sep 27, 2011 at 18:27

amit_g's user avatar

amit_gamit_g

30.7k8 gold badges61 silver badges118 bronze badges

2

Have a look at the FileHelpers library. It will do exactly what you want.

With FileHelpers, you can read from Excel files and write to csv or flat text files. And it’s object oriented! All you have to do is to annotate classes with some attributes so that they match the source excel file.

Consider this example:

[DelimitedRecord("|")]
public class CustomersVerticalBar {
   public string CustomerID;
   public string CompanyName;
   ...
}

Read using this:

ExcelStorage provider = new ExcelStorage(typeof(CustomersVerticalBar));

provider.StartRow = 3;
provider.StartColumn = 2;

provider.FileName = "Customers.xls";

CustomerVerticalBar[] res = (CustomerVerticalBar[]) provider.ExtractRecords();

Example taken from here: http://filehelpers.sourceforge.net/example_exceldatalink.html

answered Sep 27, 2011 at 18:06

Mikael Östberg's user avatar

Mikael ÖstbergMikael Östberg

17k6 gold badges61 silver badges79 bronze badges

4

.xls is a proprietary binary format which cannot be read in plain text format, so you will need office or Libre Office or something to read that… .xlsx is an xml based format, and should be possible just by parsing through the DOM… but you would still be manually iterating through each value and manually delimiting, etc. Have you considered using an xslt?

answered Sep 27, 2011 at 17:55

therealmitchconnors's user avatar

3

XLSX (EXCEL) to CSV Converter

Convert your xlsx files to csv online & free


Drop files here. 100 MB maximum file size or Sign Up

Convert to XLSX

xlsx

Office Open XML Worksheet Sheet

XLSX is a file format created with Microsoft Excel, version from 2007 and younger. This file is a spreadsheet. All data distributed document and stored in the cells. Each cell has a unique address, which is denoted by the letters and Arabic numerals. XLSX file format is based on the Open XML. To reduce the size of the file is compressed ZIP.

CSV Converter

csv

Comma-Separated Values

Is a text format used for representing tabular data. Each file line is located on a separate line in the table. The values of the columns are separated by a delimiter, most often a comma. However, other symbols can be used as delimiters as well.

How to convert XLSX to CSV

Step 1

Upload xlsx-file(s)

Select files from Computer, Google Drive, Dropbox, URL or by dragging it on the page.

Step 2

Choose «to csv»

Choose csv or any other format you need as a result (more than 200 formats supported)

Step 3

Download your csv

Let the file convert and you can download your csv file right afterwards

XLSX to CSV Quality Rating

4.7 (51,821 votes)

You need to convert and download at least 1 file to provide feedback!

Convert XLSX to CSV online and free

I tried it and immediately fell in love! It was so easy to use! After a couple conversions I bought the guys a cup of coffee. A couple more and decided this was too good to abuse! I joined! My life is so much easier!

Tillie

I had a huge, problematic file to convert that couldn’t go through the usual automated conversion process. The Zamzar team responded quickly to my request for help, and they took the extra steps needed to do it manually.

PDinSF

I’ve used this product for years. And customer service is excellent. Just had an issue where I was charged and I didn’t agree with the charge and they took care of it, even though they didn’t have to.

JH

I have been so thankful for Zamzar’s support from the beginning of the Pandemic to the present day. Their service is first rate & their helpfulness is always the best it could be.

Mary

A very useful and professional site. The service is easy to use and the administrators are helpful and courteous.

David Shelton

I use Zamar whenever I need to convert audio and video files from multiple submitters to 1 uniform file format for Audio and Video Editing. I can do multiple large files in a short amount of time.

Christopher Bee

Great for when you need a lot of conversions in a short time. You have directly access and can even put the subscription on for just a month.

Sabina Calis

Great thanks to you all for helping me to get the OLD files converted correctly. 20 years, quite a long time, reviewing the files brings much memory to me. That’s the best gift I received last year. Thank you all again.

Jiunn-Ru Lai

I feel like Zamzar is an active team member, especially for projects that I work on where I am the workhorse and it saves so much time and frustration. I am spoiled with Zamzar, because they have set the bar for file conversion and customer service very high.

Deborah Herman

Fantastic service! My mom’s computer died and she has 1000+ Word Perfect files she wants to keep for some reason. Since Word Perfect is basically dead, I decided to convert all her files. Zamzar’s converter was perfect.

Aron Boyette

Trusted by employees at these brands

Employees of some of the world’s most well-known brands rely on Zamzar to convert their files safely and efficiently, ensuring they have the formats they need for the job at hand. From global corporations and media companies, to respected educational establishments and newspaper publications, employees of these organisations trust Zamzar to provide the accurate and reliable conversion service they need.

Your files are in safe hands

Zamzar has converted over 510 million files since 2006

For every 10,000 files converted on Zamzar, we’ll plant a tree. By using Zamzar you are helping to make a difference to our planet

We’re committed to regular charitable giving. Each month we donate at least 2% of our company profits to different charities

From your personal desktop to your business files, we’ve got you covered

We offer a range of tools, to help you convert your files in the most convenient way for you. As well as our online file conversion service, we also offer a desktop app for file conversions straight from your desktop, and an API for automated file conversions for developers. Which tool you use is up to you!

Want to convert files straight from your desktop?

Get the App

Fully integrated into your desktop

Convert over 150 different file formats

Convert documents, videos, audio files in one click

Need conversion functionality within your application?

Explore the API

One simple API to convert files

100s of formats for you to choose from

Documents, videos, audios, images & more…

Why choose Zamzar?

With Zamzar, file conversions are easy, reliable and convenient, so you can quickly convert your documents, images, videos, and more, to the formats you need. With faster downloads of converted files, and friendly and helpful support when you need it, you’ll have everything you need to work with your files.

Our new design makes file conversion easy. With over 1100 file formats supported, you

Ease of Use

Our new design makes file conversion easy. With over 1100 file formats supported, you’ll never need to look anywhere else.

If there

1100+ File-conversion Types Supported

If there’s a file format that we don’t yet support, just reach out to us and we’ll try to get it added for you.

We know you might need to convert files while on the move, which is why our conversion tool works on both phone and tablet.

Any Device

We know you might need to convert files while on the move, which is why our conversion tool works on both phone and tablet.

Zamzar remained available for use during the coronavirus pandemic, and we’ll continue to support our users who need their files converted.

Available 24*7

Zamzar remained available for use during the coronavirus pandemic, and we’ll continue to support our users who need their files converted.

Tools to suit your file conversion needs

You’ll find all the conversion and compression tools you need, all in one place, at Zamzar. With over 1100 file-conversion types supported, whether you need to convert videos, audio, documents or images, you’ll easily find what you need and soon have your files in the formats and sizing that work for you.

XLSX Document Format

XLSX Converter

XLSX is a Excel file type developed by Microsoft as part of Office 2007. XLSX was developed by Microsoft as part of their Office 2007 development which focused on trying to allow information to be more readily shared between different programs whilst also reducing the file size footprint which had been increasing year on year.

XLSX files have the same functionality as XLS files in that they can include shapes, charts, formula, macros and more. The difference between the two is more technical. The XLSX file data is stored in the Open XML format which stores data as separate files and is zipped to reduce space. This is compared to the XLS file type which stores the data in a single binary file. XLSX files can be opened by various programs including various OpenOffice programs and on the web with applications like Google Drive.

Related Tools

  • Document converters

  • XLSX Converter

CSV Document Format

CSV Converter

CSV is a type of file for saving spreadsheet data which is recognised by almost all spreadsheet programs. CSV stands for ‘comma separated values’, and if you open a CSV file outside a spreadsheet program, you will see plain text with the data separated, usually by commas, semi-colons, or quotation marks. If you open that same CSV file in a spreadsheet program like Microsoft Excel, Apple Numbers, Google Sheets or LibreOffice Calc, each separated piece of data should then be transferred into an individual cell.

Because CSV files are recognised by almost all spreadsheet programs, they are used as a simple way to export data or transfer it between different programs. However, CSV is a plain text format, so CSV files cannot include advanced spreadsheet functions like charts, formulas, filters, or formatting. There is also not currently a universal open standard for all CSV files.

Related Tools

  • Document converters

  • CSV Converter

How to convert a XLSX to a CSV file?

  1. 1. Choose the XLSX file that you want to convert.
  2. 2. Select CSV as the the format you want to convert your XLSX file to.
  3. 3. Click «Convert» to convert your XLSX file.

Frequently asked questions

If you’ve got any questions about converting or compressing files with Zamzar, we’re happy to help! We’ve answered a few commonly-asked questions below, to get you started, and you can find out more information about file conversion and compression with Zamzar, in our Help centre.

There are several ways you can convert XLSX to CSV, including using Excel or conversion tools like Zamzar. In Excel, you can open an XLSX file and then save it as a CSV, or comma delimited, file. You may also be able to open your Excel file in another program like LibreOffice or Google Drive before saving it as a CSV.

The advantage of using Zamzar or another online file converter is that you can convert multiple files without opening them. Just upload the files to the free tool on Zamzar’s website and click to convert them to CSV, before downloading the converted files.

To open an XLSX file as CSV you usually need to convert it first. It’s simple to do this with the free tool on Zamzar’s website – just upload your XLSX file, select to convert it to CSV and then download your file in the new format. You can also open XLSX files with Excel or some other programs like LibreOffice or Google Drive, and then use the ‘Save As’ function to convert them to CSV format.

The free tool on Zamzar’s website is a quick automated way of converting Excel to CSV. Simply upload one or more XLS or XLSX files to Zamzar’s three-step conversion tool, click to convert them to CSV and then download the new files. You can also convert Excel files to CSV one at a time by opening them with Excel, LibreOffice or Google Drive and then exporting them as CSV format files.

You can convert XLSX to CSV without Excel by using a free alternative like LibreOffice, or with online tools like Zamzar. The conversion tool on Zamzar’s website works without the need to install software, and you can convert multiple XLSX files to CSV in just a few clicks. Just upload your XLSX files to the free online tool, select CSV and then ‘Convert Now’, before downloading the new files.

There are a few ways you can convert XLXS to CSV without losing data, including with the free tool on Zamzar’s website. You can convert multiple files at once by uploading them to the three-step tool, selecting to convert them to CSV, and then downloading the spreadsheet data in the new format.

If you want to convert or edit individual files, you can also open them with Microsoft Excel or LibreOffice, and then use the ‘Save As’ menu option to save them as new CSV files.

# Converter use https://code.google.com/p/excellibrary/ to read cells. # Place .DLL in same folder as this script. param ( [parameter(Mandatory=$false)] [alias(«source«)] [alias(«src«)] [string]$ExcelFileName, [parameter(Mandatory=$false)] [alias(«destination«)] [alias(«dest«)] [string]$CsvFileName, [parameter(Mandatory=$false)] [alias(«sheet«)] [string]$WorksheetName, [parameter(Mandatory=$false)] [alias(«d«)] [char]$delimiter = ;, [parameter(Mandatory=$false)] [alias(«h«)] [switch]$help, [parameter(Mandatory=$false)] [switch]$trace ) # Globals $defaultCulture = New-Object System.Globalization.CultureInfo(«da-DK«); $forceQuoteStringChars = («`n`r`»« + $delimiter).ToCharArray(); if($help) { Write-Output «Usage: Convert-Excel-To-Csv -SouRCe file.xls -DESTination file.csv [-sheet SheetName] [-Delimiter Char] [-Help]« Write-Output «-Help: Command usage« Write-Output «-Source: Excel source file« Write-Output «-Destination: Csv destination file« Write-Output «-Sheet: Sheet name. Default is first sheet« Write-Output «-Delimiter: Character used as field delimiter in csv file. Default is semicolon (;)« Exit } if ($ExcelFileName -eq ««) { throw «Please provide path to the Excel file« Exit } if (-not (Test-Path $ExcelFileName)) { throw «Path ‘$ExcelFileName‘ does not exist.« Exit } if ($CsvFileName -eq ««) { throw «Please provide path to the CSV file« Exit } function trace { param($message) if($trace) { Write-Host $message } } function Format-Cell-Date { param($cell,$format,$culture) Try { switch($cell.Value.GetType().FullName) { «System.String« { $cell.StringValue; } «System.Double« { $cell.DateTimeValue.ToString($format,$culture) } default { Write-Error («Unhandled type at cell: $rowIndex,$colIndex : « + $cell.Format.FormatString) exit } } } Catch { $cell.StringValue; } } $customFormats = @{}; function Get-Custom-Format { param([string]$format) $customFormat = $customFormats.Get_Item($format); if($customFormat -eq $null) { if($format -match «^([$-(?<loc>.*)])?(?<fmt>.*);@$«) { $loc = $matches.Get_Item(«loc«); $fmt = $matches.Get_Item(«fmt«); if($loc -eq $null) { $culture = $defaultCulture; } else { $culture = New-Object System.Globalization.CultureInfo([Convert]::ToInt32($loc, 16)); } switch ($fmt) { «dd mmmm yyyy« { $specifier = «D« } «ddmmmmyyyy« { $specifier = «D« } «dd/mm/yyyy« { $specifier = «d« } default { return $null } } $customFormat = @{ culture = $culture; specifier = $specifier }; $customFormats.Add($format, $customFormat); } } return $customFormat; } #load ExcelLibrary DLL $scriptPath = Split-Path $MyInvocation.MyCommand.Path trace «scriptPath: $scriptPath« $assemblyLocation = Join-Path $scriptPath «ExcelLibrary.dll « [Reflection.Assembly]::LoadFrom($assemblyLocation) | Out-Null # open xls file $book = [ExcelLibrary.SpreadSheet.WorkBook]::Load($ExcelFileName); #select sheet if ($WorksheetName) { $sheet = $book.Worksheets | ? {$_.Name -eq $WorkSheetName}; } else { $sheet = $book.Worksheets[0]; } $stream = New-Object System.IO.StreamWriter($CsvFileName,$false,[System.Text.Encoding]::Default) #Mesure cols $cols = 0; for ($rowIndex=$sheet.Cells.FirstRowIndex; $rowIndex -le $sheet.Cells.LastRowIndex; $rowIndex++) { $row = $sheet.Cells.GetRow($rowIndex); if($cols -lt $row.LastColIndex) { $cols = $row.LastColIndex } } $line = New-Object String($delimiter,$cols); for ($rowIndex=0; $rowIndex -lt $sheet.Cells.FirstRowIndex; $rowIndex++) { $stream.WriteLine($line); } $lineStringBuilder = New-Object System.Text.StringBuilder # traverse rows by Index for ($rowIndex=$sheet.Cells.FirstRowIndex; $rowIndex -le $sheet.Cells.LastRowIndex; $rowIndex++) { $row = $sheet.Cells.GetRow($rowIndex); $dummy = $lineStringBuilder.Clear(); for ($colIndex=0; $colIndex -le $cols; $colIndex++) { $value = ««; if($colIndex -ge $row.FirstColIndex -and $colIndex -le $row.LastColIndex) { $cell = $row.GetCell($colIndex); if(-not $cell.IsEmpty) { switch ($cell.Format.FormatType) { «General« {$value = $cell.StringValue;} «Custom« { $customFormat = Get-CustomFormat $cell.Format.FormatString if($customFormat -eq $null) { Write-Error («Unhandled custom format string at cell: $rowIndex,$colIndex : « + $cell.Format.FormatString) exit } $value = Format-CellDate $cell $customFormat.specifier $customFormat.culture } «Date« { switch ($cell.Format.FormatString) { «m/d/yy« { $value = Format-CellDate $cell «d« $defaultCulture } default { Write-Error («Unhandled date format string at cell: $rowIndex,$colIndex : « + $cell.Format.FormatString) exit } } } default { Write-Error («Unkbown format type at cell: $rowIndex,$colIndex : « + $cell.Format.FormatType) exit } } } } if($value.IndexOfAny($forceQuoteStringChars) -ne -1) { $value = «« + $value.Replace(««,«`»`»«) + ««; } $dummy = $lineStringBuilder.Append($value); $dummy = $lineStringBuilder.Append($delimiter); } #remove last delimiter $lineStringBuilder.Length; #write line to csv file $stream.WriteLine($lineStringBuilder); } $stream.Close(); $stream.Dispose();

Понравилась статья? Поделить с друзьями:
  • Excel to csv with delimiter
  • Excel to csv windows
  • Excel to csv npm
  • Excel to csv linux
  • Excel to count occurrences