Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

C#
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

C#
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

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


does anyone have an idea?
Posted

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[^]
 
Share this answer
 
Comments
Abhinav S 29-Aug-11 2:08am    
Good links. 5.
Fairly useful link[^], should definitely help you out.
 
Share this answer
 
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)



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