none
Design Custom Excel Class Library Best Practices RRS feed

  • General discussion

  • I am designing a class library based on Excel.Interop that has some methods to check some document property values.

    I have to package my class library code as a reusable asset in a class library that will be utilized in other applications referencing my library with the intent to create a document list report based on the detected values for large number of documents.

    I have been thinking how to design my library code, specifically on opening and disposing excel files.

    Should I add a constructor that takes a file-path and take responsibility of opening and disposing files in my library. I will need to worry about opening/disposing for all my exposed methods.

    Or should I accept only Excel objects through the constructor and give the responsibility to the referencing code to worry about opening and closing excel files (but i't will again need reference to excel.interop libraries along with as my library).

    Please provide some best practices recommendations on this.


    PM

    Friday, July 17, 2015 5:45 AM

All replies

  • Hello Paras,

    From your description, this issue is related with Excel development, so I help move it to the Excel development forum that there are Excel exeprts will help you, the current forum you posted to is used to Discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, July 20, 2015 1:31 AM
  • Hi Paras,

    In my option, both ways are OK, and it depends on your requirement. With the first method, you could pass file path to custom Excel class library, and then you could dispose excel file in the Excel class library. In this way, you could decide whether to expose your methods. With the second method, you could custom your methods in your Excel class, and with the exposed methods, you could use the methods when you need, and pass the Excel objects to your methods to dispose excel file. As you know, in this way, you need to reference to excel.interop. If you just want to pass a file, and get the reuslt of the report, I think the first method would be better. You could chose the different ways according to your requirement.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Wednesday, July 22, 2015 6:29 AM