Forums
Applications
Community
Development
Getting Started
Integrations
Aras Labs
Community Projects
Submit a Community Project
More
Cancel
Replies
1 reply
Subscribers
13 subscribers
Views
3600 views
Users
0 members are here
Options
Share
More
Cancel
Related
Getting Excel Data with Merged Cell.
Former Member
over 9 years ago
Hello All, I'm trying to get data from excel with multi marge cell. I developed codes as below. string filePath = @"D:\SGSO.xlsx"; Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application(); excelApp.Visible = true; //open the workbook Excel.Workbook workbook = excelApp.Workbooks.Open(filePath, 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); //select the first sheet Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Worksheets[1]; //find the used range in worksheet Excel.Range excelRange = worksheet.UsedRange; //get an object array of all of the cells in the worksheet (their values) object[,] valueArray = (object[,])excelRange.get_Value(Excel.XlRangeValueDataType.xlRangeValueDefault); string item = string.Empty; string poItem = string.Empty; string boxNo = string.Empty; string qry = string.Empty; string uom = string.Empty; string keurpi = string.Empty; string description = string.Empty; string sn = string.Empty; string unitprice = string.Empty; string totalprice = string.Empty; string margecell = string.Empty; string totalamount = string.Empty; int detailInital = worksheet.UsedRange.Rows.Count; for (int row = 1; row <= worksheet.UsedRange.Rows.Count; ++row) { /* For Item Detail Data */ if(valueArray[row,2] != null) { if(valueArray[row,2].ToString().ToUpper() == "ITEM") { //detailInital = row + 1; detailInital = row; } if(row>detailInital && valueArray[row,2] != null) { excelRange =(Excel.Range) worksheet.Cells[row, 2]; if(!(bool)excelRange.MergeCells) { item = valueArray[row, 2].ToString(); poItem = valueArray[row, 3].ToString(); boxNo = valueArray[row, 4].ToString(); qry = valueArray[row, 5].ToString(); uom = valueArray[row, 6].ToString(); keurpi = valueArray[row, 7].ToString(); description = valueArray[row, 8].ToString(); sn = valueArray[row, 15].ToString(); unitprice = valueArray[row, 16].ToString(); totalprice = valueArray[row, 17].ToString(); } else { margecell = valueArray[row, 2].ToString(); excelRange =(Excel.Range) worksheet.Cells[row, 17]; if(!(bool)excelRange.MergeCells) { totalamount = valueArray[row, 17].ToString(); row = worksheet.UsedRange.Rows.Count + 1; } } } } } //clean up stuffs workbook.Close(false, Type.Missing, Type.Missing); // Marshal.ReleaseComObject(workbook); excelApp.Quit(); // Marshal.FinalReleaseComObject(excelApp); These codes are ok in Visual Studio. But, In aras, I got the following Error Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). So,I tried configuration as Instruction as below link
waheedrous.wordpress.com/.../
But , Still ERROR!!! Please help. Thanks. Thiha Swe Myanmar
Parents
Offline
Jillian Jakubowicz
over 9 years ago
Hi Thiha, You will need to add your third party DLL(s) to the Innovator/Server/bin directory. Then you will need to reference the namespace in the MainCSharp template in Innovator/Server/method-config.xml. For further details and an example you can reference section 7.30 of the Programmer's Guide:
http://www.aras.com/support/documentation/11.0%20SP9/Other%20Documentation/Aras%20Innovator%2011.0%20-%20Programmer's%20Guide.pdf
. Jillian
Jillian Jakubowicz Aras Labs Software Engineer
Cancel
Vote Up
0
Vote Down
Sign in to reply
Cancel
Reply
Offline
Jillian Jakubowicz
over 9 years ago
Hi Thiha, You will need to add your third party DLL(s) to the Innovator/Server/bin directory. Then you will need to reference the namespace in the MainCSharp template in Innovator/Server/method-config.xml. For further details and an example you can reference section 7.30 of the Programmer's Guide:
http://www.aras.com/support/documentation/11.0%20SP9/Other%20Documentation/Aras%20Innovator%2011.0%20-%20Programmer's%20Guide.pdf
. Jillian
Jillian Jakubowicz Aras Labs Software Engineer
Cancel
Vote Up
0
Vote Down
Sign in to reply
Cancel
Children
No Data