Click here to Skip to main content
15,903,203 members
Home / Discussions / C#
   

C#

 
AnswerRe: string comparasion Pin
selcuks20-Aug-08 21:41
selcuks20-Aug-08 21:41 
GeneralRe: string comparasion Pin
AndieDu21-Aug-08 15:30
AndieDu21-Aug-08 15:30 
AnswerRe: string comparasion Pin
Christian Graus20-Aug-08 21:54
protectorChristian Graus20-Aug-08 21:54 
GeneralRe: string comparasion Pin
AndieDu21-Aug-08 15:31
AndieDu21-Aug-08 15:31 
QuestionA COM Interop Question Pin
Xiaoming Qian20-Aug-08 21:21
Xiaoming Qian20-Aug-08 21:21 
AnswerRe: A COM Interop Question Pin
AhsanS20-Aug-08 21:37
AhsanS20-Aug-08 21:37 
AnswerRe: A COM Interop Question Pin
Green Fuze20-Aug-08 22:35
Green Fuze20-Aug-08 22:35 
GeneralRe: A COM Interop Question Pin
Xiaoming Qian21-Aug-08 19:04
Xiaoming Qian21-Aug-08 19:04 
Thank you for your reply.But I stiil face a problem:
<br />
    private void NullAndRelease(object runtimeObject)<br />
    {<br />
      if (runtimeObject == null)<br />
        return;<br />
      try<br />
      {<br />
        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(runtimeObject);<br />
      }<br />
      finally<br />
      { <br />
        runtimeObject = null; <br />
      }<br />
    }<br />
    private void button1_Click(object sender, EventArgs e)<br />
    {<br />
      Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();<br />
      object NullParam = System.Reflection.Missing.Value;<br />
      Workbook Book = ExcelApp.Workbooks.Open(FileName, 0, true, NullParam, NullParam, NullParam,<br />
        true, NullParam, NullParam, false, false, NullParam, false, true, NullParam);<br />
      Worksheet Sheet = Book.Worksheets[1] as Worksheet;<br />
      Range UsedRange = Sheet.UsedRange;<br />
<br />
      Range Cell = null;<br />
      int RowCount = UsedRange.Rows.Count;<br />
      for (int i = 2; i <= RowCount; i++)<br />
      {<br />
        Cell = UsedRange.Cells[i, 1] as Microsoft.Office.Interop.Excel.Range;<br />
        Cell = UsedRange.Cells[i, 2] as Microsoft.Office.Interop.Excel.Range;<br />
        Cell = UsedRange.Cells[i, 3] as Microsoft.Office.Interop.Excel.Range;<br />
        Cell = UsedRange.Cells[i, 4] as Microsoft.Office.Interop.Excel.Range;<br />
        Cell = UsedRange.Cells[i, 5] as Microsoft.Office.Interop.Excel.Range;<br />
        Cell = UsedRange.Cells[i, 6] as Microsoft.Office.Interop.Excel.Range;<br />
        NullAndRelease(Cell); <br />
      }<br />
      NullAndRelease(Cell);<br />
      NullAndRelease(UsedRange);<br />
      NullAndRelease(Sheet);<br />
      if (Book != null)<br />
        Book.Close(false, NullParam, false);<br />
      NullAndRelease(Book);<br />
      ExcelApp.Quit();<br />
      NullAndRelease(ExcelApp);<br />
      GC.Collect();<br />
      GC.WaitForPendingFinalizers();       <br />
    }<br />

These code works well.But when I add the following code in the for loop:
<br />
      Cell = UsedRange.Cells[i, 7] as Microsoft.Office.Interop.Excel.Range;<br />

The server does not shut down. It seems that I can only read not more than 6 cells.That's why?
AnswerRe: A COM Interop Question [modified] Pin
selcuks20-Aug-08 22:54
selcuks20-Aug-08 22:54 
GeneralRe: A COM Interop Question Pin
JoeRip21-Aug-08 2:26
JoeRip21-Aug-08 2:26 
Questionhi friends I need help Pin
Denver Thomas20-Aug-08 21:03
Denver Thomas20-Aug-08 21:03 
AnswerRe: hi friends I need help Pin
Christian Graus20-Aug-08 21:18
protectorChristian Graus20-Aug-08 21:18 
GeneralRe: hi friends I need help Pin
Denver Thomas20-Aug-08 21:52
Denver Thomas20-Aug-08 21:52 
GeneralRe: hi friends I need help Pin
Christian Graus20-Aug-08 22:29
protectorChristian Graus20-Aug-08 22:29 
GeneralRe: hi friends I need help Pin
Denver Thomas21-Aug-08 0:18
Denver Thomas21-Aug-08 0:18 
QuestionSQL srver 2000 and C# Connection error Pin
Gulfaraz20-Aug-08 20:52
Gulfaraz20-Aug-08 20:52 
AnswerRe: SQL srver 2000 and C# Connection error Pin
Blue_Boy20-Aug-08 21:12
Blue_Boy20-Aug-08 21:12 
QuestionHow do i? Pin
Silvyster20-Aug-08 16:05
Silvyster20-Aug-08 16:05 
AnswerRe: How do i? Pin
PIEBALDconsult20-Aug-08 16:40
mvePIEBALDconsult20-Aug-08 16:40 
GeneralRe: How do i? Pin
Silvyster20-Aug-08 16:44
Silvyster20-Aug-08 16:44 
GeneralRe: How do i? Pin
PIEBALDconsult20-Aug-08 17:17
mvePIEBALDconsult20-Aug-08 17:17 
GeneralRe: How do i? Pin
JoeRip20-Aug-08 18:09
JoeRip20-Aug-08 18:09 
GeneralRe: How do i? Pin
TheFM23420-Aug-08 18:52
TheFM23420-Aug-08 18:52 
QuestionDoes Boolean not need an Interlocked.Exchange method? Pin
JoeRip20-Aug-08 15:31
JoeRip20-Aug-08 15:31 
AnswerRe: Does Boolean not need an Interlocked.Exchange method? Pin
Christian Graus20-Aug-08 15:47
protectorChristian Graus20-Aug-08 15:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.