Sample code for 30+ languages & platforms
Zig Requires Chilkat v11.3.0+

XLSX Get Sheet Names

Open an Excel spreadsheet (.xlsx) and get the names of the sheets.

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    // .xlsx files are Zip archives
    const zip = try chilkat.Zip.init();
    defer zip.deinit();
    zip.openZip("qa_data/excel/fakeCompanies.xlsx") catch {
        std.debug.print("{s}\n", .{try zip.getLastErrorText(alloc)});
        return;
    };

    const csv = try chilkat.Csv.init();
    defer csv.deinit();
    const sheet_names = try chilkat.StringTable.init();
    defer sheet_names.deinit();
    csv.xlsxGetSheets(zip, sheet_names) catch {
        std.debug.print("{s}\n", .{try csv.getLastErrorText(alloc)});
        return;
    };

    var i: i32 = 0;
    while (i < sheet_names.getCount()) {
        std.debug.print("{s}\n", .{try sheet_names.stringAt(alloc, i)});
        i = i + 1;
    }
}