gregurs Posted July 2, 2012 at 10:21 AM Report Share #466772 Posted July 2, 2012 at 10:21 AM Bom dia, tenho este código para abrir um ficheiro excel e dá-me uma messageBox com System.Object[,] e não faz nada,alguem me sabe ajudar não compreendo private void CreateExcel() { Excel.Application xlApp ; Excel.Workbook xlWorkBook ; Excel.Worksheet xlWorkSheet ; object misValue = System.Reflection.Missing.Value; xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Open("C:\\Pasta1.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); MessageBox.Show(xlWorkSheet.get_Range("B3","B4").Value2.ToString()); xlWorkBook.Close(true, misValue, misValue); xlApp.Quit(); releaseObject(xlWorkSheet); releaseObject(xlWorkBook); releaseObject(xlApp); } private void releaseObject(object obj) { try { System.Runtime.InteropServices.Marshal.ReleaseComObject(obj); obj = null; } catch (Exception ex) { obj = null; MessageBox.Show("Unable to release the Object " + ex.ToString()); } finally { GC.Collect(); } } Link to comment Share on other sites More sharing options...
bruno1234 Posted July 2, 2012 at 07:09 PM Report Share #466899 Posted July 2, 2012 at 07:09 PM O teu código executa isto: MessageBox.Show(xlWorkSheet.get_Range("B3","B4").Value2.ToString()); e depois isto: xlApp.Quit(); Não percebo bem o que pretendes. Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now