This is a migrated thread and some comments may be shown as answers.

How to insert a collection directly into cells of xlsx file in WPF?

3 Answers 69 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Srinivas
Top achievements
Rank 1
Srinivas asked on 03 Sep 2014, 08:20 AM
Is direct insertion possible??

3 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 04 Sep 2014, 04:18 PM
Hello Srinivas,

While there is no out of the box method that would do this for you, inserting the entries of a collection should be pretty straightforward if you enumerate over the collections. For example, the next snippet inserts the entries from the myData collection in the first column (A) of the active worksheet.
List<string> myData = new List<string>() { "test", "TEST", "123" };
 
for (int i = 0; i < myData.Count; i++)
{
    this.radSpreadsheet.ActiveWorksheet.Cells[i, 0].SetValue(myData[i]);
}

I hope this is useful.

Regards,
Petya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Srinivas
Top achievements
Rank 1
answered on 05 Sep 2014, 07:17 AM
What you said is valid.. but...
When I write this code‚Äč
Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
Microsoft.Office.Interop.Excel._Worksheet worksheet = null;

and append yours.I am getting output as xls file but I want xlsx file.

0
Petya
Telerik team
answered on 05 Sep 2014, 03:39 PM
Hello Srinivas,

I'm not sure what you mean. The code you sent seems to use the Microsoft Office Interop assemblies, while my suggestion and the section where this forum thread is are related to the RadSpreadsheet control which is part of the Telerik UI for WPF suite. Are you using the component in your application? If you are, please provide more details on the issue which you are experiencing.

Regards,
Petya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Spreadsheet
Asked by
Srinivas
Top achievements
Rank 1
Answers by
Petya
Telerik team
Srinivas
Top achievements
Rank 1
Share this question
or