Skip to content
This repository has been archived by the owner on Feb 6, 2021. It is now read-only.

issue with CsvHelper.excel #10

Closed
Rabi3k opened this issue Jan 3, 2018 · 4 comments
Closed

issue with CsvHelper.excel #10

Rabi3k opened this issue Jan 3, 2018 · 4 comments

Comments

@Rabi3k
Copy link

Rabi3k commented Jan 3, 2018

Dear Christiano,
I am facing an issue with CsvHelper.excel as when I attempt to use the example provided
"
using (var reader = new CsvReader(new ExcelParser("path/to/file.xlsx")))
{
var people = reader.GetRecords();
}

"

I end up with a compile error
"Severity Code Description Project File Line Suppression State
Error CS7069 Reference to type 'ICsvParser' claims it is defined in 'CsvHelper', but it could not be found Task-Manager-Excell C:\Users\rk\source\repos\Task-Manager-Excell\Task-Manager-Excell\ExcelData.cs 154 Active
"
and
"Severity Code Description Project File Line Suppression State
Error CS7069 Reference to type 'CsvConfiguration' claims it is defined in 'CsvHelper', but it could not be found Task-Manager-Excell C:\Users\rk\source\repos\Task-Manager-Excell\Task-Manager-Excell\ExcelData.cs 154 Active
"
please advise me with the proper fix for this error
Best regards,

@christophano
Copy link
Owner

What version of CsvHelper do you have referenced? The current version of CsvHelper.Excel only supports the 2.x api of CsvHelper. It's on my (massive) to do list to implement support for the 3.0+ api.

@Rabi3k
Copy link
Author

Rabi3k commented Jan 10, 2018

I have decreased the version of CsvHelper to 2.60 and the compile error has been fixed but I faced a new error that the CsvHelper.excel doesn't work with excel version higher than 12.0
and if I need to create an application that imports from both end CSV and excel that will be impossible with decreasing the CsvHelper.
Is it possible to update CsvHelper.Excel library?

@christophano
Copy link
Owner

See #3

@brettsschmidt
Copy link

brettsschmidt commented Jan 17, 2019

For anyone else who is just trying to convert UTF-8 into something Excel will read (not mess with worksheets or etc.), a work-around I found to work was to just set the Encoding in StreamWriter configuration to ANSI/Default since this is what Excel uses by default.
Example:
using(var writer = new Streamer("path\\to\\file.csv", false, Encoding.Default))
{
  using(var csv = new CsvWriter(writer))
  {
    csv.WriteRecords(mylist);
  }
}

Apologies that this isn't exactly related to the issue, but this was the first place I came across when trying to figure this out and this would have saved me an hour of research.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants