Click here to Skip to main content
14,865,310 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I have listbox and items are present in the list box and i want to convert those items to list of array of string like

var headrow = new List<string[]>
new string[] { "a" ,"b", "c" }

Please help me out and below is what is have tried and its not working

Selectedlistbox contains list items such as zebra, water, pumpkin.. When i try this the values are coming , but in the excel its is saving in one below the other rather than column header

What I have tried:

<pre>using (ExcelPackage excel = new ExcelPackage())
  var headerRow = SelectedListbox.items.cast<String[])().Tolist();
  // Determine the header range (e.g. A1:D1)
  string headerRange = "A1:" + Char.ConvertFromUtf32(headerRow[0].Length + 64) + "1";

  // Target a worksheet
  var worksheet = excel.Workbook.Worksheets["Worksheet1"];
  // Popular header row data
  FileInfo excelFile = new FileInfo(@"C:\Users\amir\Desktop\test.xlsx");
Gerry Schmitz 25-Mar-21 13:26pm
Did you bother to see if there's anything in "headerRow"? Do you know how? You think we can?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900