Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 at 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 at 29-Aug-11 2:05am
   
Nice link Abhinav. Have my 5.
Abhinav S at 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
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 204
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 183
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 29 Aug 2011
Copyright © CodeProject, 1999-2014
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