We help IT Professionals succeed at work.

Output to document does not work.

168 Views
Last Modified: 2013-12-16
       public static void OutputFooter(int count)
        {
         

            Excel.Range range0 = excelWorkSheet.get_Range("G15", "G" + (count-1).ToString());
            Excel.Range range1 = excelWorkSheet.get_Range("I15", "I" + (count-1).ToString());
            Excel.Range range2 = excelWorkSheet.get_Range("K15", "K" + (count-1).ToString());
            Excel.Range range3 = excelWorkSheet.get_Range("M15", "M" + (count-1).ToString());
            Excel.Range range4 = excelWorkSheet.get_Range("O15", "O" + (count-1).ToString());
            Excel.Range range5 = excelWorkSheet.get_Range("Q15", "Q" + (count-1).ToString());

         
            double sum0 = SumCellsInRange(range0);
            double sum1 = SumCellsInRange(range1);
            double sum2 = SumCellsInRange(range2);
            double sum3 = SumCellsInRange(range3);
            double sum4 = SumCellsInRange(range4);
            double sum5 = SumCellsInRange(range5);
            ((Excel.Range)excelWorkSheet.Cells[7, count + 2]).Value2 = sum0;
            ((Excel.Range)excelWorkSheet.Cells[9, count + 2]).Value2 = sum1;
            ((Excel.Range)excelWorkSheet.Cells[11, count + 2]).Value2 = sum2;
            ((Excel.Range)excelWorkSheet.Cells[13, count + 2]).Value2 = sum3;
            ((Excel.Range)excelWorkSheet.Cells[15, count + 2]).Value2 = sum4;
            ((Excel.Range)excelWorkSheet.Cells[17, count + 2]).Value2 = sum5;
}
this portion does not write to the excel spreadsheet.
 ((Excel.Range)excelWorkSheet.Cells[7, count + 2]).Value2 = sum0;
            ((Excel.Range)excelWorkSheet.Cells[9, count + 2]).Value2 = sum1;
            ((Excel.Range)excelWorkSheet.Cells[11, count + 2]).Value2 = sum2;
            ((Excel.Range)excelWorkSheet.Cells[13, count + 2]).Value2 = sum3;
            ((Excel.Range)excelWorkSheet.Cells[15, count + 2]).Value2 = sum4;
            ((Excel.Range)excelWorkSheet.Cells[17, count + 2]).Value2 = sum5;
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2008

Commented:
In C, don't square brackets indicate an array? Cells is a property. Try this:

   ((Excel.Range)excelWorkSheet.Cells(7, count + 2)).Value2 = sum0;

Kevin

Author

Commented:
C:\SvnWork\InitialPriceReporting\DotNet\InitialPriceReporting\clsGenerateSaleGrade.cs(289,42): error CS0118: 'Microsoft.Office.Interop.Excel._Worksheet.Cells' is a 'property' but is used like a 'method'

 ((Excel.Range)excelWorkSheet.Cells(7, count + 2)).Value2 = sum0;
            ((Excel.Range)excelWorkSheet.Cells(9, count + 2)).Value2 = sum1;
            ((Excel.Range)excelWorkSheet.Cells(11, count + 2)).Value2 = sum2;
            ((Excel.Range)excelWorkSheet.Cells(13, count + 2)).Value2 = sum3;
            ((Excel.Range)excelWorkSheet.Cells(15, count + 2)).Value2 = sum4;
            ((Excel.Range)excelWorkSheet.Cells(17, count + 2)).Value2 = sum5;
CERTIFIED EXPERT
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.