Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: DLL wrapper to umnanaged code

$
0
0
Ouch... I am feeling as a total beginner in OOP (and I am!) - want to make a csharp dll on ClosedXML to export functions to unmanaged code:
    [DllExport("OpenFileXY", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    private static bool OpenFileXY(ref TNewFile par)
    {
        XLWorkbook workbook = new XLWorkbook();
        return true;
    }

    [DllExport("AddSheet", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    public static bool AddSheet(ref TNewSheet par)
    {
        //Create a sheet - following line has an error message
        var worksheet = workbook.Worksheets.Add("Sample Sheet");
        ws.Cell("A1").Value = "Hello World!";
        ws.SaveAs(strFilename);
        return true;
    }
Exporting works just fine but: how to proceed 'workbook' from method OpnenFileXY to AddSheet, so that the sheet will be opened in a 'workbook' created with OpenFileXY?

From unmanaged code there is a code such as this:

boolFld = OpenFileXY('FileName')
boolFld = AddSheet('SheetName1')
boolFld = AddSheet('SheetName2')
boolFld = WriteString2Cell('SheetName1', col, row, value)
etc.

Any help would appreciate...

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>