Link to home
Create AccountLog in
Avatar of mathieu_cupryk
mathieu_cuprykFlag for Canada

asked on

Easy syntax fixing. C#

I converted some code :
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
                    }

Error      1      No overload for method 'Open' takes '1' arguments      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      46      1      InitialPriceReportingSpreadsheet
Error      2      '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      70      82      InitialPriceReportingSpreadsheet
Error      3      The name 'Strings' does not exist in the current context      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      71      25      InitialPriceReportingSpreadsheet
Error      4      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      71      47      InitialPriceReportingSpreadsheet
Error      5      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      73      39      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      73      78      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      80      51      InitialPriceReportingSpreadsheet
Error      8      '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      81      86      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      82      47      InitialPriceReportingSpreadsheet


from vb.net but
i have errors.

can someone help me out.
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of mathieu_cupryk

ASKER

Error      2      '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      79      84      InitialPriceReportingSpreadsheet

   cellvalue = ((Microsoft.Office.Interop.Excel.Range)inputRange).Cells(rowCount, pricesColumn);

i am stuck on this.
Error      4      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      81      47      InitialPriceReportingSpreadsheet

 if (cellvalue.Value.ToString() == "Stones" | cellvalue.Value.ToString() == "Tough")
                       
Error      9      '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      92      86      InitialPriceReportingSpreadsheet
 cellvalue = ((Microsoft.Office.Interop.Excel.Range)inputRange).Cells(rowCount, 15);
                       
another error
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      92      47      InitialPriceReportingSpreadsheet
gradeName = cellvalue.Value.ToString();
I got some done.
 if (Strings.Len(cellvalue.Value2) > 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 = Int32.Parse(cellvalue.Value2.ToString());

                        cellvalue.Value2 = Cells[rowCount, 15];
                        gradeName = cellvalue.Value2.ToString();

                        Insert_Price_List_Detail(gradeName, Price);
                        // insert the prices
                    }

is this ok?
do you have compiler error messages?