Click here to Skip to main content
12,063,645 members (70,599 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# WPF MS-Excel Interop
I know how to write single cell into excel but when im trying it on array excel sheet is filling with only last value

this is my range

Excel.Range ServiceName = (Excel.Range)_sheet.get_Range(_sheet.Cells[38, "B"] as Excel.Range, _sheet.Cells[45, "B"] as Excel.Range);

_ServiceName is List which contains 1,2,3,4,5,6

for (int i = 0; i < _ServiceName.Count; i++)
            {
                ServiceNameArray[0, i] = _ServiceName[i];
 
            }

this i my trying to write into excel but as i said it there is only last item (6) in excel book

for (int i = 0; i < _ServiceName.Count; i++)
           {
               ServiceName.set_Value(Type.Missing, ServiceNameArray[0,i]);
           }

does anyone have an idea?
Posted 28-Aug-11 13:30pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I think there is some problem in getting range of excel cells.
You can find a VB.Net article on this here. Go to third section Object Pasting Method, I have used Range to populate the Excel Sheet.

Or these link might help you.

http://stackoverflow.com/questions/536636/write-array-to-excel-range[^]

http://support.microsoft.com/kb/302096[^]
  Permalink  
Comments
Abhinav S 29-Aug-11 2:08am
   
Good links. 5.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Fairly useful link[^], should definitely help you out.
  Permalink  
Comments
Suresh Suthar 29-Aug-11 2:05am
   
Nice link Abhinav. Have my 5.
Abhinav S 29-Aug-11 2:07am
   
Thanks Suresh.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160204.4 | Last Updated 29 Aug 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100