Non-Visual access to spread in a dll

Posted by: donfinsoft on 8 September 2017, 2:52 pm EST

  • Posted 8 September 2017, 2:52 pm EST

    I have the latest Spread.Net Version 6 bundle.  I have used the version and it works great, i am now creating a windows DLL that needs to convert excel files into pdf's, so i was going to use spread for this.  So its a class project in VS2010 that i will compile into a DLL for other programs to call and convert xls files to pdf's.   How do i call Spread from a DLL when there is no forms to place the spread control on.   I need to access the spread calc engine or similar to open an excel file and perform the conversion. 

  • Replied 8 September 2017, 2:52 pm EST


    You might be better off creating the class and passing the code to those who need to use it, as you will get licensing problems trying to use FpSpread from a DLL like you describe.  Even if you manually add the licenses.licx with the FpSpread's type info to the DLL project and make it an embedded resource, the framework will not allow that embedded license to be used to create the control for clients of your DLL.  Those clients would need to add the FpSpread's type into the licenses.licx for their EXE project, as if they are using FpSpread directly, so having the code in a DLL is less convenient that just having the source code.

    If you really want to built the code into a DLL, you could do it in a UserControl, and if you don't create any FpSpread in design time (which should not be necessary for what you describe) then it should not require the Spread license if the UserControl is licensed.  I made a blog post about this use case and how component licensing operates that you can refer to for more info:

    <h4 class="BlogPostHeader">Licensing of .NET Components</h4>

    You can create a FpSpread in code and use it without hosting it in a form to do what you describe.  You don't need to have the control hosted on a form to load an Excel file or print to PDF.

  • Replied 8 September 2017, 2:52 pm EST

    Thanks for getting back to me so quickly, its greatly appreciated. I will look into creating a user control for this purpose.  

  • Replied 8 September 2017, 2:52 pm EST

    How would i access spread in without using a user control or a window?
  • Replied 8 September 2017, 2:52 pm EST


    You can reference Spread in a DLL project and call it from a class that isn't a user control or window.  The code won't work without the license for Spread though.  If it's run in a design time context, it will always require the development license for Spread to be present on the computer.  That's why I suggested just passing the class code to those you want to use it, rather than building it into a dll, because it won't work to pass the license check that way.  The run time license must be built into the resources for an EXE target.

    But you can use FpSpread in any kind of managed code project, even a console application or web service that has no GUI, if the computer is licensed for development with Spread.  You just can't redistribute code using FpSpread in libraries (i.e. dlls) to other developers who aren't themselves licensed for Spread development.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels