Solved

small excell conversion from vb.net to c#.

Posted on 2008-06-10
6
430 Views
Last Modified: 2013-12-17
I have the following:
  private void ProcessSpreadsheet(string filename)
        {
            Microsoft.Office.Interop.Excel.Application xlApp;
            // Excel application object
            Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
            // Excel Workbook object
            Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
            // Excel Worksheet object
            Microsoft.Office.Interop.Excel.Range inputRange;
            // Excel Worksheet Range object
            int rowCount;
            int currRow;
            // row iterator
            string gradeName;
            // character input variables
            double Price;
            // price as a decimal number
            Microsoft.Office.Interop.Excel.Range cellvalue;
            double[,] discounts = new double[5, 4];
            int pricesColumn;

            // Define the input SS and open the 1st worksheet
            xlApp = new Microsoft.Office.Interop.Excel.Application();
            xlWorkBook = xlApp.Workbooks.Open(filename);
            xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.Item(1);

            // Store the rows and columns used in the input SS into inputRange
            inputRange = xlWorkSheet.UsedRange;

            // Read all used rows in the input SS, starting at the 11th row (rows are numbered from 0)
            // Data of interest is in columns O and R (numbered 15 and 18 respectively)

            for (rowCount = 10; rowCount <= inputRange.Rows.Count; rowCount++)
            {
                // Read the grade name and price
                // skip rows where the grade name is empty
                try
                {
                    // Initial prices load file has the prices in column 16
                    // All other load files have their prices in column 18
                    if (initialButton.Checked == true)
                    {
                        pricesColumn = 16;
                    }
                    else
                    {
                        pricesColumn = 18;
                    }
                    cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells(rowCount, pricesColumn);
                    if (Strings.Len(cellvalue.Value) > 0)
                    {
                        if (cellvalue.Value.ToString == "Stones" | cellvalue.Value.ToString == "Tough")
                        {
                            // all prices have been read
                            currRow = rowCount + 1;
                            // skip a row to where the discounts are
                            break; // TODO: might not be correct. Was : Exit For
                        }
                        Price = (double)cellvalue.Value;
                        cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells(rowCount, 15);
                        gradeName = cellvalue.Value.ToString;
                        Insert_Price_List_Detail(gradeName, Price);
                        // insert the prices
                    }
                }
                catch
                {
                    Console.WriteLine("Exception has occurred.");
                }
            }

            // Process discounts
            for (rowCount = currRow; rowCount <= currRow + 3; rowCount++)
            {
                // Read the discounts
                try
                {
                    cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells(rowCount, 16);
                    if (Strings.Len(cellvalue.Value) > 0)
                    {
                        discounts[rowCount - currRow, 0] = (double)cellvalue.Value;
                        cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells(rowCount, 17);
                        discounts[rowCount - currRow, 1] = (double)cellvalue.Value;
                        cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells(rowCount, 18);
                        if (cellvalue.Value.ToString != "N/A")
                        {
                            // Des Barley is the last discount
                            discounts[rowCount - currRow, 2] = (double)cellvalue.Value;
                            Update_Price_List_Header_with_Discounts(discounts);
                            // save the discounts
                            break; // TODO: might not be correct. Was : Exit For
                        }
                        else
                        {
                            discounts[rowCount - currRow, 2] = 0;
                        }
                    }
                }
                catch
                {
                    Console.WriteLine("Exception has occurred.");
                }
            }

            inputRange = null;
            xlWorkSheet = null;
            if (xlWorkBook != null)
            {
                xlWorkBook.Close(false);
            }
            xlWorkBook = null;
            if (xlApp != null)
            {
                xlApp.Quit();
            }
            xlApp = null;

        }

Error      1      Cannot apply indexing with [] to an expression of type 'method group'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      37      26      InitialPriceReportingSpreadsheet
Error      2      Property, indexer, or event 'Item' is not supported by the language; try directly calling accessor method 'Microsoft.Office.Interop.Excel.Sheets.get_Item(object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      38      91      InitialPriceReportingSpreadsheet
Error      3      The name 'initialButton' does not exist in the current context      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      54      25      InitialPriceReportingSpreadsheet
Error      4      'Microsoft.Office.Interop.Excel.Range.Cells' is a 'property' but is used like a 'method'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      62      82      InitialPriceReportingSpreadsheet
Error      5      The name 'Strings' does not exist in the current context      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      63      25      InitialPriceReportingSpreadsheet
Error      6      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      63      47      InitialPriceReportingSpreadsheet
Error      7      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      65      39      InitialPriceReportingSpreadsheet
Error      8      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      65      78      InitialPriceReportingSpreadsheet
Error      9      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      72      51      InitialPriceReportingSpreadsheet
Error      10      'Microsoft.Office.Interop.Excel.Range.Cells' is a 'property' but is used like a 'method'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      73      86      InitialPriceReportingSpreadsheet
Error      11      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      74      47      InitialPriceReportingSpreadsheet
Error      12      'Microsoft.Office.Interop.Excel.Range.Cells' is a 'property' but is used like a 'method'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      91      82      InitialPriceReportingSpreadsheet
Error      13      The name 'Strings' does not exist in the current context      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      92      25      InitialPriceReportingSpreadsheet
Error      14      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      92      47      InitialPriceReportingSpreadsheet
Error      15      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      94      78      InitialPriceReportingSpreadsheet
Error      16      'Microsoft.Office.Interop.Excel.Range.Cells' is a 'property' but is used like a 'method'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      95      86      InitialPriceReportingSpreadsheet
Error      17      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      96      78      InitialPriceReportingSpreadsheet
Error      18      'Microsoft.Office.Interop.Excel.Range.Cells' is a 'property' but is used like a 'method'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      97      86      InitialPriceReportingSpreadsheet
Error      19      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      98      39      InitialPriceReportingSpreadsheet
Error      20      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      101      82      InitialPriceReportingSpreadsheet
Error      21      No overload for method 'Close' takes '1' arguments      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      122      17      InitialPriceReportingSpreadsheet

Private Sub Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        Dim xlApp As Excel.Application               ' Excel application object
        Dim xlWorkBook As Excel.Workbook             ' Excel Workbook object
        Dim xlWorkSheet As Excel.Worksheet           ' Excel Worksheet object
        Dim inputRange As Excel.Range                ' Excel Worksheet Range object
        Dim rowCount, currRow As Integer             ' row iterator 
        Dim gradeName As String                      ' character input variables
        Dim Price As Double                          ' price as a decimal number
        Dim cellvalue As Excel.Range
        Dim discounts(4, 3) As Double
        Dim pricesColumn As Integer
 
        ' Define the input SS and open the 1st worksheet
        xlApp = New Excel.Application
        xlWorkBook = xlApp.Workbooks.Open(txtFileInput.Text)
        xlWorkSheet = CType(xlWorkBook.Worksheets.Item(1), Excel.Worksheet)
 
        ' Store the rows and columns used in the input SS into inputRange
        inputRange = xlWorkSheet.UsedRange
 
        ' Read all used rows in the input SS, starting at the 11th row (rows are numbered from 0)
        ' Data of interest is in columns O and R (numbered 15 and 18 respectively)
 
        For rowCount = 10 To inputRange.Rows.Count
            ' Read the grade name and price
            ' skip rows where the grade name is empty
            Try
                ' Initial prices load file has the prices in column 16
                ' All other load files have their prices in column 18
                If initialButton.Checked = True Then
                    pricesColumn = 16
                Else
                    pricesColumn = 18
                End If
                cellvalue = CType(inputRange.Cells(rowCount, pricesColumn), Excel.Range)
                If Len(cellvalue.Value) > 0 Then
                    If cellvalue.Value.ToString = "Stones" Or cellvalue.Value.ToString = "Tough" Then ' all prices have been read
                        currRow = rowCount + 1 ' skip a row to where the discounts are
                        Exit For
                    End If
                    Price = CDbl(cellvalue.Value)
                    cellvalue = CType(inputRange.Cells(rowCount, 15), Excel.Range)
                    gradeName = cellvalue.Value.ToString
                    Insert_Price_List_Detail(gradeName, Price) ' insert the prices
                End If
            Catch
                Console.WriteLine("Exception has occurred.")
            End Try
        Next
 
        ' Process discounts
        For rowCount = currRow To currRow + 3
            ' Read the discounts
            Try
                cellvalue = CType(inputRange.Cells(rowCount, 16), Excel.Range)
                If Len(cellvalue.Value) > 0 Then
                    discounts(rowCount - currRow, 0) = CDbl(cellvalue.Value)
                    cellvalue = CType(inputRange.Cells(rowCount, 17), Excel.Range)
                    discounts(rowCount - currRow, 1) = CDbl(cellvalue.Value)
                    cellvalue = CType(inputRange.Cells(rowCount, 18), Excel.Range)
                    If cellvalue.Value.ToString <> "N/A" Then ' Des Barley is the last discount
                        discounts(rowCount - currRow, 2) = CDbl(cellvalue.Value)
                        Update_Price_List_Header_with_Discounts(discounts) ' save the discounts
                        Exit For
                    Else
                        discounts(rowCount - currRow, 2) = 0
                    End If
                End If
            Catch
                Console.WriteLine("Exception has occurred.")
            End Try
        Next
 
        inputRange = Nothing
        xlWorkSheet = Nothing
        If xlWorkBook IsNot Nothing Then
            xlWorkBook.Close(False)
        End If
        xlWorkBook = Nothing
        If xlApp IsNot Nothing Then
            xlApp.Quit()
        End If
        xlApp = Nothing
 
        ' Disable the "Open" button, so the user knows the file has been
        ' processed
        btnOpen.Enabled = False
    End Sub

Open in new window

0
Comment
Question by:mathieu_cupryk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 21756891

        private void ProcessSpreadsheet(string filename)
        {
            Microsoft.Office.Interop.Excel.Application xlApp;
            // Excel application object 
            Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
            // Excel Workbook object 
            Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
            // Excel Worksheet object 
            Microsoft.Office.Interop.Excel.Range inputRange;
            // Excel Worksheet Range object 
            int rowCount;
            int currRow;
            // row iterator 
            string gradeName;
            // character input variables 
            double Price;
            // price as a decimal number 
            Microsoft.Office.Interop.Excel.Range cellvalue;
            double[,] discounts = new double[5, 4];
            int pricesColumn;
 
            // Define the input SS and open the 1st worksheet 
            xlApp = new Microsoft.Office.Interop.Excel.Application();
            xlWorkBook = xlApp.Workbooks.Open(filename, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
            xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets[1];
 
            // Store the rows and columns used in the input SS into inputRange 
            inputRange = xlWorkSheet.UsedRange;
 
            // Read all used rows in the input SS, starting at the 11th row (rows are numbered from 0) 
            // Data of interest is in columns O and R (numbered 15 and 18 respectively) 
 
            for (rowCount = 10; rowCount <= inputRange.Rows.Count; rowCount++)
            {
                // Read the grade name and price 
                // skip rows where the grade name is empty 
                try
                {
                    // Initial prices load file has the prices in column 16 
                    // All other load files have their prices in column 18 
                    if (initialButton.Checked == true)
                    {
                        pricesColumn = 16;
                    }
                    else
                    {
                        pricesColumn = 18;
                    }
                    cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount,pricesColumn];
                    if (cellvalue.Value2.ToString().Length > 0)
                    {
                        if (cellvalue.Value2.ToString() == "Stones" | cellvalue.Value2.ToString() == "Tough")
                        {
                            // all prices have been read 
                            currRow = rowCount + 1;
                            // skip a row to where the discounts are 
                            break; // TODO: might not be correct. Was : Exit For 
                        }
                        Price = (double)cellvalue.Value2;
                        cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount, 15];
                        gradeName = cellvalue.Value2.ToString();
                        Insert_Price_List_Detail(gradeName, Price);
                        // insert the prices 
                    }
                }
                catch
                {
                    Console.WriteLine("Exception has occurred.");
                }
            }
 
            // Process discounts 
            for (rowCount = currRow; rowCount <= currRow + 3; rowCount++)
            {
                // Read the discounts 
                try
                {
                    cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount,16];
                    if (cellvalue.Value2.ToString().Length > 0)
                    {
                        discounts[rowCount - currRow, 0] = (double)cellvalue.Value2;
                        cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount, 17];
                        discounts[rowCount - currRow, 1] = (double)cellvalue.Value2;
                        cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount, 18];
                        if (cellvalue.Value2.ToString() != "N/A")
                        {
                            // Des Barley is the last discount 
                            discounts[rowCount - currRow, 2] = (double)cellvalue.Value2;
                            Update_Price_List_Header_with_Discounts(discounts);
                            // save the discounts 
                            break; // TODO: might not be correct. Was : Exit For 
                        }
                        else
                        {
                            discounts[rowCount - currRow, 2] = 0;
                        }
                    }
                }
                catch
                {
                    Console.WriteLine("Exception has occurred.");
                }
            }
 
            inputRange = null;
            xlWorkSheet = null;
            if (xlWorkBook != null)
            {
                xlWorkBook.Close(false, filename, null);
            }
            xlWorkBook = null;
            if (xlApp != null)
            {
                xlApp.Quit();
            }
            xlApp = null;
 
        } 

Open in new window

0
 

Author Closing Comment

by:mathieu_cupryk
ID: 31465996
did u copy my solution? lol
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 21757022
yep.. i copied and changed the lines with error :-)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mathieu_cupryk
ID: 21757032
is there errors below:

  private void ProcessSpreadsheet(string filename, string LoadTypeName)
        {
            Microsoft.Office.Interop.Excel.Application xlApp;
            // Excel application object
            Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
            // Excel Workbook object
            Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
            // Excel Worksheet object
            Microsoft.Office.Interop.Excel.Range inputRange;
            // Excel Worksheet Range object
            int rowCount;
            int currRow=0;
            // row iterator
            string gradeName;
            // character input variables
            int Price;
            // price as a decimal number
            Microsoft.Office.Interop.Excel.Range cellvalue;
            Microsoft.Office.Interop.Excel.Range Cells;
            int[,] discounts = new int[5, 4];
            int pricesColumn = 0;

            // Define the input SS and open the 1st worksheet
            xlApp = new Microsoft.Office.Interop.Excel.Application();
         
            xlWorkBook = xlApp.Workbooks.Open(filename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
        Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

             xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
           
            // Store the rows and columns used in the input SS into inputRange
            inputRange = xlWorkSheet.UsedRange;

     
            // Read all used rows in the input SS, starting at the 11th row (rows are numbered from 0)
            // Data of interest is in columns O and R (numbered 15 and 18 respectively)
            for (rowCount = 10; rowCount <= inputRange.Rows.Count; rowCount++)
            {
                // Read the grade name and price
                // skip rows where the grade name is empty

                // Initial prices load file has the prices in column 16
                // All other load files have their prices in column 18
                switch (LoadTypeName)
                {
                    case "Initial": pricesColumn = 16; break;
                    case "Adjustment": pricesColumn = 18; break;

                }
                try
                {
                 
                    cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount, pricesColumn];
             
                    if (cellvalue.ToString().Length > 0)
                    {
                        if (cellvalue.ToString() == "Stones" | cellvalue.ToString() == "Tough")
                        {
                            // all prices have been read
                            currRow = rowCount + 1;
                            // skip a row to where the discounts are
                            break; // TODO: might not be correct. Was : Exit For
                        }
                        Price = Int32.Parse(cellvalue.Value2.ToString());

                        cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount, 15];
                        gradeName = cellvalue.ToString();

                        Insert_Price_List_Detail(gradeName, Price);
                        // insert the prices
                    }
                   
                }
                catch
                {
                    Console.WriteLine("Exception has occurred.");
                }
            }
           
           
            // Process discounts
            for (rowCount = currRow; rowCount <= currRow + 3; rowCount++)
            {
                // Read the discounts
                try
                {
                      cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount, 16];
                      if (cellvalue.Value2.ToString().Length > 0)
                      {
                          discounts[rowCount - currRow, 0] = (int)cellvalue.Value2;
                          cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount, 17];

                          discounts[rowCount - currRow, 1] = (int)cellvalue.Value2;
                          cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells[rowCount, 18];
                         
                          if (cellvalue.Value2.ToString() != "N/A")
                          {
                             // Des Barley is the last discount
                             discounts[rowCount - currRow, 2] = (int)cellvalue.Value2;
                             Update_Price_List_Header_with_Discounts(discounts);
                            // save the discounts
                             break; // TODO: might not be correct. Was : Exit For
                          }
                          else
                          {
                            discounts[rowCount - currRow, 2] = 0;
                          }
                      }
                }
                catch
                {
                    Console.WriteLine("Exception has occurred.");
                }
            }

            inputRange = null;
            xlWorkSheet = null;
            if (xlWorkBook != null)
            {
               xlWorkBook.Close(false,Type.Missing,Type.Missing);
            }
            xlWorkBook = null;
            if (xlApp != null)
            {
              xlApp.Quit();
            }
            xlApp = null;
           


        }
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 21757036
no.. i think..why giving u any error ?
0
 

Author Comment

by:mathieu_cupryk
ID: 21757040
cool
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question