Skip to content

ExcelDnaPack: Add support for packing any kind of resourceΒ #331

@augustoproiete

Description

@augustoproiete

Relates to #329.

It would be useful if ExcelDnaPack could be adapted to allow any kind of file to be embedded in the -packed.xll file.

We could include a new element e.g.Resource to the .dna schema that allows the user to specify the file path along with some (optional) metadata (e.g. Type), combined with an API exposed by ExcelDna.Integration that gives the developer access to the resources packed.

e.g.

<?xml version="1.0" encoding="utf-8"?>
<DnaLibrary Name="Add-In" RuntimeVersion="v4.0" xmlns="http://schemas.excel-dna.net/addin/2018/05/dnalibrary">
  <ExternalLibrary Path="AddIn.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" IncludePdb="true" />
  <!-- ... -->

  <Resource Path="NativeLibrary_32.dll" Type="NATIVELIB" Pack="true" />
  <Resource Path="NativeLibrary_64.dll" Type="NATIVELIB" Pack="true" />

  <Resource Path="Template.xlsx" Type="XLSX" Pack="true" />
</DnaLibrary>

public static class ExcelDnaUtil
{
    /// <summary>Returns the names of all the resources packed in the XLL.</summary>
    /// <returns>An enumerable that contains the names of all the resources.</returns>
    public static IEnumerable<string> GetPackedResourceNames() { ... }

    /// <summary>Loads the specified resource from the XLL.</summary>
    /// <param name="name">The case-sensitive name of the resource being requested.</param>
    /// <returns>The resource; or <see langword="null" /> if the resource does not exist in the XLL.</returns>
    public static Stream GetPackedResourceStream(string name) { ... }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions