Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Excel functions using Infragistics.Excel
posted

Hi

I do see some samples that says we can use Infragistics.Excel to work with MS Excel objects.

My requirement is that after exporting the Grid to Excel (excel1.xls), I want to read excel2.xls and paste few content on excel1.xls.  Below is the code that I used with MS Excel Object Lib 11.0  But for some reason, I get automation error on the server (it runs just fine on my development machine).  So, thought of using Infragistics.Excel for this simple purpose.  Would you please help to get Infragistics.Excel equivalent?

oBOMDataWB = oXL.Workbooks.Open(strDataXLPath) 'grid exported data

oXLTemplateWB = oXL.Workbooks.Open(strTemplatePath) 'Template that has logo image and format.

oXLTemplateWB.Sheets(1).Range("A1", "AZ9").EntireRow.Copy() 'reading cell by cell will not get correct format, so use EntireRow.Copy()

oBOMDataWB.Sheets(1).Paste()

'Hide the header data rows

oRange = oBOMDataWB.Sheets(1).Range("A10", "A24")

oRange.EntireRow.Hidden = True

oBOMDataWB.Save()

oBOMDataWB.Close()

  • 44743
    posted

    To use code like this, you need to have Excel installed on your server. If you do not, you can try to use the Infragistics.Excel assembly, but some of the things you are doing above would need to be done manually. The WorksheetRow object does not support copying and pasting, so you would need to manually transfer values and formatting to individual cells in the row. In addition, the Infragistics.Excel assembly does not support opening template files, so it might not even be possible to accomplish this with the current features of the assembly. The WorksheetRow does have a Hidden property which you could set to True.