2

I'm trying to print a CSV file with List & Label. I need to sort it by one of the columns, however the sort property is not available. If I use a SQL data source, I can sort it. How can I sort the CSV data? My source is

CsvDataProvider csvDta = new CsvDataProvider(@"C:\temp\myData.csv", true, "Data", ';');

using (ListLabel LL = new ListLabel() { DataSource = csvDta})
{
   LL.Design();
}
4
  • What is ListLabel?
    – ADyson
    Feb 22, 2018 at 10:06
  • The CsvDataProvider? is this from a nuget package? it would seam that you need to define a class to represent your data row and put the output of your csv into a collection of this class. then you would have access to linq extension methods
    – Chao226
    Feb 22, 2018 at 10:15
  • I edited the question to contain the suitable namespaces. It's one of the classes that ships with List & Label (a reporting package, see tag description for the tag listlabel)
    – JBartlau
    Feb 22, 2018 at 10:25
  • My edit got rejected :( - don't know why. So I'm adding the namespaces to the answer below insted.
    – JBartlau
    Feb 22, 2018 at 13:05

1 Answer 1

2

A simple way would be to wrap the CSV data in an InMemoryDataProvider. Try this:

using combit.ListLabel23;
using combit.ListLabel23.DataProviders;

CsvDataProvider csvDta = new CsvDataProvider(@"C:\temp\myData.csv", true, "Data", ';');

// wrap the table in a queryable data source
InMemoryDataProvider dataSource = new InMemoryDataProvider();
dataSource.AddTable(csvDta, "Data");

using (ListLabel LL = new ListLabel() { DataSource = dataSource})
{
   LL.Design();
}

This will give you all the glory of sorting and filtering you require.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.