GithubHelp home page GithubHelp logo

symmetryinvestments / xlsxd Goto Github PK

View Code? Open in Web Editor NEW
18.0 6.0 6.0 15.39 MB

A thin wrapper around libxlsx to write excel spreadsheets

License: BSD 3-Clause "New" or "Revised" License

Makefile 1.69% D 14.33% CMake 0.53% Objective-C 0.02% Shell 0.31% Perl 0.28% CSS 0.47% HTML 0.53% C 72.59% Ruby 0.05% Python 1.59% Batchfile 0.02% SAS 0.03% Ada 1.55% Assembly 2.46% Pascal 1.31% C# 0.97% C++ 0.79% M4 0.01% DIGITAL Command Language 0.48%
dlang excel data-science libxlsxwriter

xlsxd's Introduction

libxlsxd

Build Status

A small wrapper in the D programming language around the C library libxlsxwriter, which writes Excel spreadsheets.

Example

import libxlsxd;

void main() {
    /* Create a new workbook and add a worksheet.
	Workbook is RefCounted and will write the file
	when it is released.
	*/
    auto workbook  = newWorkbook("demo.xlsx");
    auto worksheet = workbook.addWorksheet(null);

    /* Add a format. */
    auto format = workbook.addFormat();

    /* Set the bold property for the format */
    format.setBold();

    /* Change the column width for clarity. */
    worksheet.setColumn(0, 0, 20);

    /* Write some simple text. */
    worksheet.writeString(0, 0, "Hello");

    /* Text with formatting. */
    worksheet.writeString(1, 0, "World", format);

    /* Write some numbers. */
    worksheet.writeNumber(2, 0, 123);
    worksheet.writeNumber(3, 0, 123.456);

	// for the lazy
    worksheet.write(4, 0, 13.37);
	// for the lazy
    worksheet.write(4, 1, true);

    worksheet.write(4, 2, "Hello 1337");
	worksheet.setColumn(4, 2, 20.0);
}

API

Consult https://libxlsxwriter.github.io/index.html for the api documentation.

The D code:

Workbook wb;
Format f = wb.addFormat();

is basically equivalent to this C code:

lxw_workbook  *workbook
lxw_format *f = workbook_add_format(workbook);

So to find the documentation for the method "methodName" for the data structure "Datastructure", search for a C function "toLower(Datastructure)_toSnakeCase(methodName)". In this example "datastructure_method_name".

Complementary Projects

xlsxd can only write xlsx files, but there are more things to do

  • xlsx can read xlsx files
  • excel-d can create excel plugins

Updating libxlsxwriter

libxlsxwriter is integrated as a squashed git subtree. The command:

git subtree pull --prefix=libxlsxwriter --squash https://github.com/jmcnamara/libxlsxwriter master

will update that subtree to the current master of the libxlsxwriter repo. Then remove source/libxlsxd/xlsxwrap.d and then run

make source/libxlsxd/xlsxwrap.d

About Kaleidic Associates

We are a boutique consultancy that advises a small number of hedge fund clients. We are not accepting new clients currently, but if you are interested in working either remotely or locally in London or Hong Kong, and if you are a talented hacker with a moral compass who aspires to excellence then feel free to drop me a line: laeeth at kaleidic.io

We work with our partner Symmetry Investments, and some background on the firm can be found here:

http://symmetryinvestments.com/about-us/

xlsxd's People

Contributors

burner avatar john-colvin avatar kinke avatar white-116 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

xlsxd's Issues

compile error in windows

git 1.0.2, and compile in windows (vs 15, mingw64), report not found zlib.
so, build zlib 1.2.11 by vs 15, then copy zlib.lib into xlsxd\libxlsxwriter\lib and zlib.h into xlsxd\libxlsxwriter\include. rebuild xlsxd:
dub build --build=release --arch=x86_64 --compiler=ldc2
also report not found zlib:
CMake Error at cmake/FindPackage.cmake:180 (message):
Unable to find requested ZLIB libraries.
how to solve this problem ?

segmentation fault with when closing workbook

import std.stdio;

void main()
{
    import libxlsxd;

    auto workbook  = newWorkbook("test.xlsx");
    scope(exit) {
        workbook.close();
    }
    auto worksheet = workbook.addWorksheet("Sheet name");
    foreach (ushort i; 0..10) {
        worksheet.writeString(0,i, "a");
    }
}

dub output

(dmd-2.098.0)emilper@home:~/testing_ground/dlang/libxlsxwriter$ dub
Performing "debug" build using /home/emilper/dlang/dmd-2.098.0/linux/bin64/dmd for x86_64.
xlsxd 4.0.1: target for configuration "library" is up to date.
libxlsxwriter ~master: target for configuration "application" is up to date.
To force a rebuild of up-to-date targets, run again with --force.
Running libxlsxwriter 
Program exited with code -11

gdb output

(dmd-2.098.0)emilper@home:~/testing_ground/dlang/libxlsxwriter$ gdb libxlsxwriter 
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from libxlsxwriter...
(gdb) r
Starting program: /home/emilper/testing_ground/dlang/libxlsxwriter/libxlsxwriter 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x000055555564dcc9 in workbook_close ()
(gdb) 

Read file

Hello, nice tool and very handy. Is there plans to add support for reading cells?

How to replace WriteFormulaNum

My app use your (great) xlsxd 1.2.3:

...
dependency "xlsxd" version="~>1.2.3"

I want upgrade to 3.1.6

dependency "xlsxd" version="~>3.1.6"

but:

no property writeFormulaNum for type Worksheet

I have tried with writeFormulaNumImpl but does't work..

So, which is the function that replaces writeFormulaNum?

Thank you very much

Corrupted output with `workbook.addWorksheet(null)`

I've found that when I use this and at least Excel 2016 I've got an error that the file is broken (fix by excel works fine).

It's unexpectedly caused by this: https://github.com/kaleidicassociates/xlsxd/blob/master/source/libxlsxd/workbook.d#L58

And it's because std.string.toStringz returns empty string when called with null. So there is empty named sheet in the output which caused the error.
See https://github.com/dlang/phobos/blob/master/std/string.d#L311

I'm not sure what to do with this. I would expect that toStringz would return null for null input. So this is probably Phobos bug or should we "fix" it in this library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.