packages feed

libxls (empty) → 0.2

raw patch · 18 files changed

+1811/−0 lines, 18 filesdep +basedep +bindings-DSLbuild-type:Customsetup-changedbinary-added

Dependencies added: base, bindings-DSL

Files

+ LICENSE view
@@ -0,0 +1,2 @@+MIT license JUST FOR THE HASKELL SOURCE PART+The c library libxls-0.3.0_pre107.tar.bz2 FOLLOWS IT OWN LICENSE CONSTRAINT
+ README view
@@ -0,0 +1,24 @@+libxls可用来读取xls格式文档。++** cabal configure+** cabal build+** cabal install+** cabal repl --ghc-options=-Llib --ghc-options=-lxlsreader++openBook :: String -> String -> IO WorkBook+            |         |+            xls文档   解码方式(UTF-8 ASCII)++openSheet :: WorkBook -> Int -> IO WorkSheet+                         |+                         sheet号码++getCell :: WorkSheet -> Int -> Int -> IO CellData+                        |      |+                        x      y++showCellInfo :: CellData -> IO ()++更多用法请参考 Bindings.Libxls 和 src/Data/Libxls++** 绑定自libxls c语言库
+ Setup.hs view
@@ -0,0 +1,147 @@+{-# LANGUAGE RecordWildCards #-}+import Distribution.Verbosity +import Distribution.Simple.Setup+import Distribution.Simple.BuildPaths+import Distribution.PackageDescription+import Distribution.Simple+import Distribution.Simple.Utils+import Distribution.Simple.LocalBuildInfo+import Distribution.Simple.Program+import Distribution.Simple.Program.Find+import Distribution.Simple.Program.Db++import System.FilePath ((</>), (<.>))+import System.Directory++import Control.Exception+import Control.Monad++confProgram, makeProgram :: Program+confProgram = simpleProgram "configure"+makeProgram = simpleProgram "make"++main :: IO ()+main = do +    curDir <- getCurrentDirectory+    let confProgram' = confProgram+            { programFindLocation = \_ _ -> return . Just $  curDir </> "libxls-0.3.0_pre107" </> "configure"+            }++    defaultMainWithHooks simpleUserHooks +        { confHook = xlsConfHook+        , buildHook = myBuildHook+        , copyHook = xlsCopyHook+        , hookedPrograms = hookedPrograms simpleUserHooks ++ [confProgram', makeProgram]+        }++myBuildHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()+myBuildHook pkg lbi usrHooks flags = do+    curDir <- getCurrentDirectory+++    let verbosity = fromFlag $ buildVerbosity flags+        library' = case library pkg of+            Just l -> Just $ l { libBuildInfo = (libBuildInfo l) { extraLibs = "xlsreader" : []+                                                                 , extraLibDirs = [curDir </> "lib"]+                                                                 }+                                } +            Nothing -> library pkg+        pkg' = pkg { library = library' }+    +        lbi' = case lookupProgram ghcProgram (withPrograms lbi) of+                Just ghc -> +                    let pdb = updateProgram (ghc { programOverrideArgs = ["-optl-Wl,-rpath," ++ libdir (absoluteInstallDirs pkg lbi NoCopyDest)] }) (withPrograms lbi)+                    in+                        lbi { withPrograms = pdb }+                Nothing -> lbi++    inDir (curDir </> "build") $+        runDbProgram verbosity makeProgram (withPrograms lbi) ["install"]+    +    let xlslib = "lib" ++ "xlsreader" <.> dllExtension+    isLibExist <- doesFileExist $ curDir </> "lib" </> xlslib+    unless isLibExist $ die "Error Compiling libxls !!!"++    buildHook simpleUserHooks pkg' lbi' usrHooks flags++    notice verbosity "Making The STATIC Library"+    let mylib = curDir </> "lib" </> mkStaticLib "xlsreader"+    forM_ (libName lbi') $ \lib -> do+        inDir (buildDir lbi) $ do+            runAr verbosity lbi ["-M"] $ arScript ([mylib, lib]) lib++xlsConfHook :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo+xlsConfHook (pkg, hbi) flags = do+    let verbosity = fromFlag (configVerbosity flags)+    curDir <- getCurrentDirectory+    lbi <- confHook simpleUserHooks (pkg, hbi) flags++    let xlsRepoDir = curDir </> "libxls-0.3.0_pre107"+        xlsBuildDir = curDir </> "build"+        xlsPfxDir = xlsBuildDir </> "dist"+        xlsLibDir = curDir </> "lib"++    createDirectoryIfMissingVerbose verbosity True xlsBuildDir+    createDirectoryIfMissingVerbose verbosity True xlsPfxDir+    createDirectoryIfMissingVerbose verbosity True xlsLibDir+    notice verbosity "Configuring libxls ..."++    xlsExist <- doesFileExist "libxls-0.3.0_pre107.tar.bz2"+    unless xlsExist $ die "No libxls source tar package found"+    runTar verbosity lbi ["axvf", "libxls-0.3.0_pre107.tar.bz2"]++    inDir xlsBuildDir $ +        runDbProgram verbosity confProgram (withPrograms lbi)+            [ "--libdir=" ++ xlsLibDir+            , "--prefix=" ++ xlsPfxDir +            ]++    return lbi++xlsCopyHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()+xlsCopyHook pkg lbi usrHooks flags = do+  copyHook simpleUserHooks pkg lbi usrHooks flags++  curDir <- getCurrentDirectory+  let xlsLibDir = curDir </> "lib"+      verbosity = fromFlag (copyVerbosity flags)+      destdir = fromFlagOrDefault NoCopyDest $ copyDest flags+      libCopyDir = libdir $ absoluteInstallDirs pkg lbi destdir++  notice verbosity $ "Installing libxls shared libraries (" ++ show libCopyDir ++ ") ..."+  copyFiles verbosity libCopyDir [(xlsLibDir, "lib" ++ "xlsreader" <.> dllExtension ++ ".0")]++mkStaticLib :: String -> String+mkStaticLib name = mkLibName (LibraryName name)++runTar :: Verbosity -> LocalBuildInfo -> [String] -> IO ()+runTar v lbi args = do+    case lookupProgram tarProgram (withPrograms lbi) of+        Nothing -> die "No <tar command> found!"+        Just ar -> runProgramInvocation v $ (programInvocation ar args)++runAr :: Verbosity -> LocalBuildInfo -> [String] -> String -> IO ()+runAr v lbi args script = do+    case lookupProgram arProgram (withPrograms lbi) of+        Nothing -> die "No <ar> found!"+        Just ar -> runProgramInvocation v $ (programInvocation ar args) { progInvokeInput = Just script }++arScript :: [String] -> String -> String+arScript libs name = unlines $ ["CREATE " ++ name]+                            ++ map ("ADDLIB " ++) libs+                            ++ ["SAVE", "END"]++inDir :: FilePath -> IO () -> IO ()+inDir dir act = do+    curDir <- getCurrentDirectory+    bracket_ (setCurrentDirectory dir)+             (setCurrentDirectory curDir)+             act++libName :: LocalBuildInfo -> [String]+libName lbi = +    concatMap pick (componentsConfigs lbi)+  where+    pick :: (ComponentName, ComponentLocalBuildInfo, [ComponentName]) -> [String]+    pick (_, LibComponentLocalBuildInfo {..}, _) = map mkLibName $ componentLibraries   +    pick _ = []
+ include/brdb.c.h view
@@ -0,0 +1,200 @@+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *+ *+ * This file is part of libxls -- A multiplatform, C library+ * for parsing Excel(TM) files.+ *+ * libxls is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Lesser General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * libxls is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+ * GNU Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with libxls.  If not, see <http://www.gnu.org/licenses/>.+ * + * Copyright 2004 Komarov Valery+ * Copyright 2006 Christophe Leitienne+ * Copyright 2008 David Hoerl+ */++{ 0x00, "Unknown",	""},+{ 0x06, "FORMULA",	"Cell Formula" },+{ 0x09, "BOF-BIFF2",	"Beginning of File" },+{ 0x0A, "EOF",	"End of File" },+{ 0x0C, "CALCCOUNT",	"Iteration Count" },+{ 0x0D, "CALCMODE",	"Calculation Mode" },+{ 0x0E, "PRECISION",	"Precision" },+{ 0x0F, "REFMODE",	"Reference Mode" },+{ 0x10, "DELTA",	"Iteration Increment" },+{ 0x11, "ITERATION",	"Iteration Mode" },+{ 0x12, "PROTECT",	"Protection Flag" },+{ 0x13, "PASSWORD",	"Protection Password" },+{ 0x14, "HEADER",	"Print Header on Each Page" },+{ 0x15, "FOOTER",	"Print Footer on Each Page" },+{ 0x16, "EXTERNCOUNT",	"Number of External References" },+{ 0x17, "EXTERNSHEET",	"External Reference" },+{ 0x19, "?WINDOWPROTECT",	" (biffview guessed)" },+{ 0x1A, "VERTICALPAGEBREAKS",	"Explicit Column Page Breaks" },+{ 0x1B, "HORIZONTALPAGEBREAKS",	"Explicit Row Page Breaks" },+{ 0x1C, "NOTE",	"Comment Associated with a Cell" },+{ 0x1D, "SELECTION",	"Current Selection" },+{ 0x22, "DATEMODE",	"1904 Date System" },+{ 0x26, "LEFTMARGIN",	"Left Margin Measurement" },+{ 0x27, "RIGHTMARGIN",	"Right Margin Measurement" },+{ 0x28, "TOPMARGIN",	"Top Margin Measurement" },+{ 0x29, "BOTTOMMARGIN",	"Bottom Margin Measurement" },+{ 0x2A, "PRINTHEADERS",	"Print Row/Column Labels" },+{ 0x2B, "PRINTGRIDLINES",	"Print Gridlines Flag" },+{ 0x2F, "FILEPASS",	"File Is Password-Protected" },+{ 0x31, "FONT",	"Font Description" },+{ 0x3C, "CONTINUE",	"Continues Long Records" },+{ 0x3D, "WINDOW1",	"Window Information" },+{ 0x40, "BACKUP",	"Save Backup Version of the File" },+{ 0x41, "PANE",	"Number of Panes and Their Position" },+{ 0x42, "CODEPAGE",	"Default Code Page" },+{ 0x4D, "PLS",	"Environment-Specific Print Record" },+{ 0x50, "DCON",	"Data Consolidation Information" },+{ 0x51, "DCONREF",	"Data Consolidation References" },+{ 0x52, "DCONNAME",	"Data Consolidation Named References" },+{ 0x55, "DEFCOLWIDTH",	"Default Width for Columns" },+{ 0x59, "XCT",	"CRN Record Count" },+{ 0x5A, "CRN",	"Nonresident Operands" },+{ 0x5B, "FILESHARING",	"File-Sharing Information" },+{ 0x5C, "WRITEACCESS",	"Write Access User Name" },+{ 0x5D, "OBJ",	"Describes a Graphic Object" },+{ 0x5E, "UNCALCED",	"Recalculation Status" },+{ 0x5F, "SAVERECALC",	"Recalculate Before Save" },+{ 0x60, "TEMPLATE",	"Workbook Is a Template" },+{ 0x63, "OBJPROTECT",	"Objects Are Protected" },+{ 0x7D, "COLINFO",	"Column Formatting Information" },+{ 0x7F, "IMDATA",	"Image Data" },+{ 0x80, "GUTS",	"Size of Row and Column Gutters" },+{ 0x81, "WSBOOL",	"Additional Workspace Information" },+{ 0x82, "GRIDSET",	"State Change of Gridlines Option" },+{ 0x83, "HCENTER",	"Center Between Horizontal Margins" },+{ 0x84, "VCENTER",	"Center Between Vertical Margins" },+{ 0x85, "BOUNDSHEET",	"Sheet Information" },+{ 0x86, "WRITEPROT",	"Workbook Is Write-Protected" },+{ 0x87, "ADDIN",	"Workbook Is an Add-in Macro" },+{ 0x88, "EDG",	"Edition Globals" },+{ 0x89, "PUB",	"Publisher" },+{ 0x8C, "COUNTRY",	"Default Country and WIN.INI Country" },+{ 0x8D, "HIDEOBJ",	"Object Display Options" },+{ 0x90, "SORT",	"Sorting Options" },+{ 0x91, "SUB",	"Subscriber" },+{ 0x92, "PALETTE",	"Color Palette Definition" },+{ 0x94, "LHRECORD",	".WK? File Conversion Information" },+{ 0x95, "LHNGRAPH",	"Named Graph Information" },+{ 0x96, "SOUND",	"Sound Note" },+{ 0x99, "STANDARDWIDTH",	"Standard Column Width" },+{ 0x98, "LPR",	"Sheet Was Printed Using LINE.PRINT" },+{ 0x9A, "FNGROUPNAME",	"Function Group Name" },+{ 0x9B, "FILTERMODE",	"Sheet Contains Filtered List" },+{ 0x9C, "FNGROUPCOUNT",	"Built-in Function Group Count" },+{ 0x9D, "AUTOFILTERINFO",	"Drop-Down Arrow Count" },+{ 0x9E, "AUTOFILTER",	"AutoFilter Data" },+{ 0xA0, "SCL",	"Window Zoom Magnification" },+{ 0xA1, "SETUP",	"Page Setup" },+{ 0xA9, "COORDLIST",	"Polygon Object Vertex Coordinates" },+{ 0xAB, "GCW",	"Global Column-Width Flags" },+{ 0xAE, "SCENMAN",	"Scenario Output Data" },+{ 0xAF, "SCENARIO",	"Scenario Dataç" },+{ 0xB0, "SXVIEW",	"View Definition" },+{ 0xB1, "SXVD",	"View Fields" },+{ 0xB2, "SXVI",	"View Item" },+{ 0xB4, "SXIVD",	"Row/Column Field IDs" },+{ 0xB5, "SXLI",	"Line Item Array" },+{ 0xB6, "SXPI",	"Page Item" },+{ 0xB8, "DOCROUTE",	"Routing Slip Information" },+{ 0xB9, "RECIPNAME",	"Recipient Name" },+{ 0xBC, "SHRFMLA",	"Shared Formula" },+{ 0xBD, "MULRK",	"Multiple RK Cells" },+{ 0xBE, "MULBLANK",	"Multiple Blank Cells" },+{ 0xC1, "MMS",	"ADDMENU/DELMENU Record Group Count" },+{ 0xC2, "ADDMENU",	"Menu Addition" },+{ 0xC3, "DELMENU",	"Menu Deletion" },+{ 0xC5, "SXDI",	"Data Item" },+{ 0xC6, "SXDB",	"PivotTable Cache Data" },+{ 0xCD, "SXSTRING",	"String" },+{ 0xD0, "SXTBL",	"Multiple Consolidation Source Info" },+{ 0xD1, "SXTBRGIITM",	"Page Item Name Count" },+{ 0xD2, "SXTBPG",	"Page Item Indexes" },+{ 0xD3, "OBPROJ",	"Visual Basic Project" },+{ 0xD5, "SXIDSTM",	"Stream ID" },+{ 0xD6, "RSTRING",	"Cell with Character Formatting" },+{ 0xD7, "DBCELL",	"Stream Offsets" },+{ 0xDA, "BOOKBOOL",	"Workbook Option Flag" },+{ 0xDC, "PARAMQRY-SXEXT",	"Query Parameters-External Source Information" },+{ 0xDD, "SCENPROTECT",	"Scenario Protection" },+{ 0xDE, "OLESIZE",	"Size of OLE Object" },+{ 0xDF, "UDDESC",	"Description String for Chart Autoformat" },+{ 0xE0, "XF",	"Extended Format" },+{ 0xE1, "INTERFACEHDR",	"Beginning of User Interface Records" },+{ 0xE2, "INTERFACEEND",	"End of User Interface Records" },+{ 0xE3, "SXVS",	"View Source" },+{ 0xE5, "CSPAN",	"Cells span" },+{ 0xEA, "TABIDCONF",	"Sheet Tab ID of Conflict History" },+{ 0xEB, "MSODRAWINGGROUP",	"Microsoft Office Drawing Group" },+{ 0xEC, "MSODRAWING",	"Microsoft Office Drawing" },+{ 0xED, "MSODRAWINGSELECTION",	"Microsoft Office Drawing Selection" },+{ 0xF0, "SXRULE",	"PivotTable Rule Data" },+{ 0xF1, "SXEX",	"PivotTable View Extended Information" },+{ 0xF2, "SXFILT",	"PivotTable Rule Filter" },+{ 0xF6, "SXNAME",	"PivotTable Name" },+{ 0xF7, "SXSELECT",	"PivotTable Selection Information" },+{ 0xF8, "SXPAIR",	"PivotTable Name Pair" },+{ 0xF9, "SXFMLA",	"PivotTable Parsed Expression" },+{ 0xFB, "SXFORMAT",	"PivotTable Format Record" },+{ 0xFC, "SST",	"Shared String Table" },+{ 0xFD, "LABELSST",	"Cell Value, String Constant/SST" },+{ 0xFF, "EXTSST",	"Extended Shared String Table" },+{ 0x100, "SXVDEX",	"Extended PivotTable View Fields" },+{ 0x103, "SXFORMULA",	"PivotTable Formula Record" },+{ 0x122, "SXDBEX",	"PivotTable Cache Data" },+{ 0x13D, "TABID",	"Sheet Tab Index Array" },+{ 0x160, "USESELFS",	"Natural Language Formulas Flag" },+{ 0x161, "DSF",	"Double Stream File" },+{ 0x162, "XL5MODIFY",	"Flag for DSF" },+{ 0x1A5, "FILESHARING2",	"File-Sharing Information for Shared Lists" },+{ 0x1A9, "USERBVIEW",	"Workbook Custom View Settings" },+{ 0x1AA, "USERSVIEWBEGIN",	"Custom View Settings" },+{ 0x1AB, "USERSVIEWEND",	"End of Custom View Records" },+{ 0x1AD, "QSI",	"External Data Range" },+{ 0x1AE, "SUPBOOK",	"Supporting Workbook" },+{ 0x1AF, "PROT4REV",	"Shared Workbook Protection Flag" },+{ 0x1B0, "CONDFMT",	"Conditional Formatting Range Information" },+{ 0x1B1, "CF",	"Conditional Formatting Conditions" },+{ 0x1B2, "DVAL",	"Data Validation Information" },+{ 0x1B5, "DCONBIN",	"Data Consolidation Information" },+{ 0x1B6, "TXO",	"Text Object" },+{ 0x1B7, "REFRESHALL",	"Refresh Flag" },+{ 0x1B8, "HLINK",	"Hyperlink" },+{ 0x1BB, "SXFDBTYPE",	"SQL Datatype Identifier" },+{ 0x1BC, "PROT4REVPASS",	"Shared Workbook Protection Password" },+{ 0x1BE, "DV",	"Data Validation Criteria" },+{ 0x200, "DIMENSIONS",	"Cell Table Size" },+{ 0x201, "BLANK",	"Cell Value, Blank Cell" },+{ 0x203, "NUMBER",	"Cell Value, Floating-Point Number" },+{ 0x204, "LABEL",	"Cell Value, String Constant" },+{ 0x205, "BOOLERR",	"Cell Value, Boolean or Error" },+{ 0x207, "STRING",	"String Value of a Formula" },+{ 0x208, "ROW",	"Describes a Row" },+{ 0x209, "BOF-BIFF3",	"Beginning of File" },+{ 0x20B, "INDEX",	"Index Record" },+{ 0x218, "NAME",	"Defined Name" },+{ 0x221, "ARRAY",	"Array-Entered Formula" },+{ 0x223, "EXTERNNAME",	"Externally Referenced Name" },+{ 0x225, "DEFAULTROWHEIGHT",	"Default Row Height" },+{ 0x236, "TABLE",	"Data Table" },+{ 0x23E, "WINDOW2",	"Sheet Window Information" },+{ 0x27E, "RK",	"Cell Value, RK Number" },+{ 0x293, "STYLE",	"Style Information" },+{ 0x409, "BOF-BIFF4",	"Beginning of File" },+{ 0x41E, "FORMAT",	"Number Format" },+{ 0x4BC, "?FORMULA-RELATED=?(BC=SHRFMLA))",	"Formula related, always before there are 0x06 (FORMULA)" },+{ 0x809, "BOF-BIFF5/7/8",	"Beginning of File" },+{ 0xFFF, "",	"" },
+ include/brdb.h view
@@ -0,0 +1,52 @@+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *+ *+ * This file is part of libxls -- A multiplatform, C library+ * for parsing Excel(TM) files.+ *+ * libxls is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Lesser General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * libxls is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+ * GNU Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with libxls.  If not, see <http://www.gnu.org/licenses/>.+ * + * Copyright 2004 Komarov Valery+ * Copyright 2006 Christophe Leitienne+ * Copyright 2008 David Hoerl+ */+#include <stdio.h>+#include "xlsstruct.h"++struct str_brdb+{+    WORD opcode;+    char * name;			/* printable name */+    char * desc;			/* printable description */+};+typedef struct str_brdb record_brdb;++record_brdb brdb[] =+    {+#include "brdb.c.h"+    };++static int get_brbdnum(int id)+{++    int i;+    i=0;+    do+    {+        if (brdb[i].opcode==id)+            return i;+        i++;+    }+    while (brdb[i].opcode!=0xFFF);+    return 0;+}
+ include/ole.h view
@@ -0,0 +1,149 @@+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *+ *+ * This file is part of libxls -- A multiplatform, C library+ * for parsing Excel(TM) files.+ *+ * libxls is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Lesser General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * libxls is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+ * GNU Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with libxls.  If not, see <http://www.gnu.org/licenses/>.+ * + * Copyright 2004 Komarov Valery+ * Copyright 2006 Christophe Leitienne+ * Copyright 2008 David Hoerl+ */++#ifndef OLE_INCLUDE+#define OLE_INCLUDE++#pragma pack(1)++#include <stdio.h>			// FILE *+#include "xlstypes.h"++typedef struct TIME_T+{+    DWORD	LowDate;+    DWORD	HighDate;+}+TIME_T;++typedef struct OLE2Header+{+    DWORD		id[2];		//D0CF11E0 A1B11AE1+    DWORD		clid[4];+    WORD		verminor;	//0x3e+    WORD		verdll;		//0x03+    WORD		byteorder;+    WORD		lsectorB;+    WORD		lssectorB;++    WORD		reserved1;+    DWORD		reserved2;+    DWORD		reserved3;++    DWORD		cfat;			// count full sectors+    DWORD		dirstart;++    DWORD		reserved4;++    DWORD		sectorcutoff;	// min size of a standard stream ; if less than this then it uses short-streams+    DWORD		sfatstart;		// first short-sector or EOC+    DWORD		csfat;			// count short sectors+    DWORD		difstart;		// first sector master sector table or EOC+    DWORD		cdif;			// total count+    DWORD		MSAT[109];		// First 109 MSAT+}+OLE2Header;+++//-----------------------------------------------------------------------------------+typedef struct +{+    char*	name;+    DWORD	start;+    DWORD	size;+}st_olefiles_data;+typedef	struct st_olefiles+{+    long count;+    st_olefiles_data* file;+}+st_olefiles;++typedef struct OLE2+{+    FILE*		file;+    WORD		lsector;+    WORD		lssector;+    DWORD		cfat;+    DWORD		dirstart;++    DWORD		sectorcutoff;+    DWORD		sfatstart;+    DWORD		csfat;+    DWORD		difstart;+    DWORD		cdif;+    DWORD*		SecID;	// regular sector data+	DWORD*		SSecID;	// short sector data+	BYTE*		SSAT;	// directory of short sectors+    st_olefiles	files;+}+OLE2;++typedef struct OLE2Stream+{+    OLE2*	ole;+    DWORD	start;+    DWORD	pos;+    int		cfat;+    int		size;+    DWORD	fatpos;+    BYTE*	buf;+    DWORD	bufsize;+    BYTE	eof;+	BYTE	sfat;	// short+}+OLE2Stream;++typedef struct PSS+{+    BYTE	name[64];+    WORD	bsize;+    BYTE	type;		//STGTY+#define PS_EMPTY		00+#define PS_USER_STORAGE	01+#define PS_USER_STREAM	02+#define PS_USER_ROOT	05+    BYTE	flag;		//COLOR+#define BLACK	1+    DWORD	left;+    DWORD	right;+    DWORD	child;+    WORD	guid[8];+    DWORD	userflags;+    TIME_T	time[2];+    DWORD	sstart;+    DWORD	size;+    DWORD	proptype;+}+PSS;++extern int ole2_read(void* buf,long size,long count,OLE2Stream* olest);+extern OLE2Stream* ole2_sopen(OLE2* ole,DWORD start, int size);+extern void ole2_seek(OLE2Stream* olest,DWORD ofs);+extern OLE2Stream*  ole2_fopen(OLE2* ole,char* file);+extern void ole2_fclose(OLE2Stream* ole2st);+extern OLE2* ole2_open(char *file, char *charset);+extern void ole2_close(OLE2* ole2);+extern void ole2_bufread(OLE2Stream* olest);++#endif
+ include/xls.h view
@@ -0,0 +1,48 @@+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *+ *+ * This file is part of libxls -- A multiplatform, C library+ * for parsing Excel(TM) files.+ *+ * libxls is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Lesser General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * libxls is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+ * GNU Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with libxls.  If not, see <http://www.gnu.org/licenses/>.+ *+ * Copyright 2004 Komarov Valery+ * Copyright 2006-2009 Christophe Leitienne+ * Copyright 2008-2009 David Hoerl+ */++#include "xlstool.h"++extern const char* xls_getVersion(void);++extern int xls_debug;++extern int xls(void);++extern void xls_addSST(xlsWorkBook* pWB,SST* sst,DWORD size);+extern void xls_appendSST(xlsWorkBook* pWB,BYTE* buf,DWORD size);++extern void xls_addFormat(xlsWorkBook* pWB,FORMAT* format);+extern void xls_parseWorkBook(xlsWorkBook* pWB);+extern void xls_parseWorkSheet(xlsWorkSheet* pWS);++extern xlsWorkBook* xls_open(char *file,char* charset);+#define xls_close xls_close_WB                  // historical+extern void xls_close_WB(xlsWorkBook* pWB);     // preferred name++extern xlsWorkSheet * xls_getWorkSheet(xlsWorkBook* pWB,int num);+extern void xls_close_WS(xlsWorkSheet* pWS);++// utility function+xlsRow *xls_row(xlsWorkSheet* pWS, WORD cellRow);+xlsCell	*xls_cell(xlsWorkSheet* pWS, WORD cellRow, WORD cellCol);
+ include/xlsstruct.h view
@@ -0,0 +1,429 @@+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *+ *+ * This file is part of libxls -- A multiplatform, C library+ * for parsing Excel(TM) files.+ *+ * libxls is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Lesser General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * libxls is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+ * GNU Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with libxls.  If not, see <http://www.gnu.org/licenses/>.+ *+ * Copyright 2004 Komarov Valery+ * Copyright 2006-2009 Christophe Leitienne+ * Copyright 2008-2009 David Hoerl+ */++#include "ole.h"++typedef struct +{+    WORD id;+    WORD size;+}+BOF;++typedef struct +{+    WORD ver;+    WORD type;+    WORD id_make;+    WORD year;+    DWORD flags;+    DWORD min_ver;+    BYTE buf[100];+}+BIFF;++typedef struct +{+    WORD xWn;+    WORD yWn;+    WORD dxWn;+    WORD dyWn;+    WORD grbit;+    WORD itabCur;+    WORD itabFirst;+    WORD ctabSel;+    WORD wTabRatio;+}+WIND1;++typedef struct +{+    DWORD	filepos;+    BYTE	type;+    BYTE	visible;+    BYTE	name[];+}+BOUNDSHEET;++typedef struct +{+    WORD	index;+    WORD	fcell;+    WORD	lcell;+    WORD	height;+    WORD	notused;+    WORD	notused2; //used only for BIFF3-4+    WORD	flags;+    WORD	xf;+}+ROW;++typedef struct +{+    WORD	row;+    WORD	col;+    WORD	xf;+}+COL;+++typedef struct  // BIFF8+{+    WORD	row;+    WORD	col;+    WORD	xf;+    //	ULLONG  res;+    BYTE	resid;+    BYTE	resdata[5];+    WORD	res;+    //	double	res;+    WORD	flags;+    BYTE	chn[4]; // BIFF8+    WORD	len;+    BYTE	value[1]; //var+}+FORMULA;++typedef struct +{+    WORD	row;+    WORD	col;+    WORD	xf;+    BYTE	value[1]; // var+}+RK;++typedef struct +{+    WORD	row;+    WORD	col;+    WORD	xf;+    BYTE	value[1];+}+LABELSST;++typedef struct +{+    WORD	row;+    WORD	col;+    WORD	xf;+}+BLANK;++typedef struct +{+    WORD	row;+    WORD	col;+    WORD	xf;+    BYTE	value[1]; // var+}+LABEL;++typedef struct +{+    DWORD	num;+    DWORD	numofstr;+    BYTE	strings;+}+SST;++typedef struct +{+    WORD	font;+    WORD	format;+    WORD	type;+    WORD	align;+    WORD	color;+    WORD	fill;+    WORD	border;+    WORD	linestyle;+}+XF5;++typedef struct +{+    WORD	font;+    WORD	format;+    WORD	type;+    BYTE	align;+    BYTE	rotation;+    BYTE	ident;+    BYTE	usedattr;+    DWORD	linestyle;+    DWORD	linecolor;+    WORD	groundcolor;+}+XF8;++typedef struct +{+    WORD	row;+    WORD	col;+    WORD	xf;+    double value;+}+BR_NUMBER;++typedef struct +{+    WORD	first;+    WORD	last;+    WORD	width;+    WORD	xf;+    WORD	flags;+    WORD	notused;+}+COLINFO;++typedef struct +{+    WORD	rowf;+    WORD	rowl;+    WORD	colf;+    WORD	coll;+}+MERGEDCELLS;++typedef struct +{+    WORD	height;+    WORD	flag;+    WORD	color;+    WORD	bold;+    WORD	escapement;+    BYTE	underline;+    BYTE	family;+    BYTE	charset;+    BYTE	notused;+    BYTE	name;+}+FONT;++typedef struct +{+    WORD	index;+    BYTE	value[0];+}+FORMAT;++//---------------------------------------------------------+typedef struct +{+    DWORD filepos;+    BYTE visibility;+    BYTE type;+    char* name;+}st_sheet_data;+typedef struct +{+    DWORD count;        //Count of sheets+    st_sheet_data* sheet;+}+st_sheet;++typedef struct +{+    WORD	height;+    WORD	flag;+    WORD	color;+    WORD	bold;+    WORD	escapement;+    BYTE	underline;+    BYTE	family;+    BYTE	charset;+    char*	name;+}st_font_data;++typedef struct +{+    DWORD count;		//Count of FONT's+    st_font_data* font;+}+st_font;++typedef struct +{+     WORD index;+     char *value;+}st_format_data;++typedef struct +{+    DWORD count;		//Count of FORMAT's+    st_format_data* format;+}+st_format;++typedef struct +{+    WORD	font;+    WORD	format;+    WORD	type;+    BYTE	align;+    BYTE	rotation;+    BYTE	ident;+    BYTE	usedattr;+    DWORD	linestyle;+    DWORD	linecolor;+    WORD	groundcolor;+} st_xf_data;++typedef struct +{+    DWORD count;	//Count of XF+    //	XF** xf;+    st_xf_data xf;+}+st_xf;++typedef struct +{+    //	long len;+    char* str;+} str_sst_string;+++typedef struct +{+    DWORD count;+    DWORD lastid;+    DWORD continued;+    DWORD lastln;+    DWORD lastrt;+    DWORD lastsz;+    str_sst_string* string;+}+st_sst;++typedef struct +{+    WORD	id;+    WORD	row;+    WORD	col;+    WORD	xf;+    double	d;+    long	l;+    char*	str;		//String value;+    BYTE	ishiden;	//Is cell hidden+    WORD	width;		//Width of col+    WORD	colspan;+    WORD	rowspan;+} st_cell_data;+++typedef struct +{+    DWORD count;+    st_cell_data* cell;+}+st_cell;++typedef struct +{+    WORD index;+    WORD fcell;+    WORD lcell;+    WORD height;+    WORD flags;+    WORD xf;+    BYTE xfflags;+    st_cell cells;+} st_row_data;++typedef struct +{+    //	DWORD count;+    WORD lastcol;+    WORD lastrow;+    st_row_data* row;+}+st_row;++typedef struct +{+    WORD	first;+    WORD	last;+    WORD	width;+    WORD	xf;+    WORD	flags;+}st_colinfo_data;++typedef struct +{+    DWORD count;	//Count of COLINFO+    st_colinfo_data* col;+}+st_colinfo;++typedef struct +{+    //FILE*		file;		//+    OLE2Stream*	olestr;+    long		filepos;	//position in file++    //From Header (BIFF)+    BYTE		is5ver;+    WORD		type;++    //Other data+    WORD		codepage;	//Charset codepage+    char*		charset;+    st_sheet	sheets;+    st_sst		sst;		//SST table+    st_xf		xfs;		//XF table+    st_font		fonts;+    st_format	formats;	//FORMAT table++	char		*summary;		// ole file+	char		*docSummary;	// ole file+}+xlsWorkBook;++typedef struct +{+    DWORD		filepos;+    WORD		defcolwidth;+    st_row		rows;+    xlsWorkBook * 	workbook;+    st_colinfo	colinfo;+    WORD		maxcol;+}+xlsWorkSheet;++typedef st_cell_data xlsCell;+typedef st_row_data xlsRow;++typedef struct +{+	char		*title;+	char		*subject;+	char		*author;+	char		*keywords;+	char		*comment;+	char		*lastAuthor;+	char		*appName;+	char		*category;+	char		*manager;+	char		*company;+}+xlsSummaryInfo;
+ include/xlstool.h view
@@ -0,0 +1,101 @@+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *+ *+ * This file is part of libxls -- A multiplatform, C library+ * for parsing Excel(TM) files.+ *+ * libxls is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Lesser General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * libxls is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+ * GNU Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with libxls.  If not, see <http://www.gnu.org/licenses/>.+ * + * Copyright 2004 Komarov Valery+ * Copyright 2006 Christophe Leitienne+ * Copyright 2008 David Hoerl+ */++#include "xlsstruct.h"++static const DWORD colors[] =+    {+        0x000000,+        0xFFFFFF,+        0xFF0000,+        0x00FF00,+        0x0000FF,+        0xFFFF00,+        0xFF00FF,+        0x00FFFF,+        0x800000,+        0x008000,+        0x000080,+        0x808000,+        0x800080,+        0x008080,+        0xC0C0C0,+        0x808080,+        0x9999FF,+        0x993366,+        0xFFFFCC,+        0xCCFFFF,+        0x660066,+        0xFF8080,+        0x0066CC,+        0xCCCCFF,+        0x000080,+        0xFF00FF,+        0xFFFF00,+        0x00FFFF,+        0x800080,+        0x800000,+        0x008080,+        0x0000FF,+        0x00CCFF,+        0xCCFFFF,+        0xCCFFCC,+        0xFFFF99,+        0x99CCFF,+        0xFF99CC,+        0xCC99FF,+        0xFFCC99,+        0x3366FF,+        0x33CCCC,+        0x99CC00,+        0xFFCC00,+        0xFF9900,+        0xFF6600,+        0x666699,+        0x969696,+        0x003366,+        0x339966,+        0x003300,+        0x333300,+        0x993300,+        0x993366,+        0x333399,+        0x333333+    };++void dumpbuf(char* fname,long size,BYTE* buf);+void verbose(char* str);+char* unicode_decode(const BYTE *s, int len, int *newlen, const char* encoding);+char* get_string(BYTE *s,BYTE is2, BYTE isUnicode, char *charset);+DWORD xls_getColor(const WORD color,WORD def);++extern void xls_showBookInfo(xlsWorkBook* pWB);+extern void xls_showROW(st_row_data* row);+extern void xls_showColinfo(st_colinfo_data* col);+extern void xls_showCell(st_cell_data* cell);+extern void xls_showFont(st_font_data* font);+extern void xls_showXF(XF8* xf);+extern void xls_showFormat(st_format_data* format);+extern char* xls_getfcell(xlsWorkBook* pWB,st_cell_data* cell);+extern char* xls_getCSS(xlsWorkBook* pWB);+extern void xls_showBOF(BOF* bof);
+ include/xlstypes.h view
@@ -0,0 +1,35 @@+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *+ *+ * This file is part of libxls -- A multiplatform, C library+ * for parsing Excel(TM) files.+ *+ * libxls is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Lesser General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * libxls is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public License+ * along with libxls.  If not, see <http://www.gnu.org/licenses/>.+ * + * Copyright 2004 Komarov Valery+ * Copyright 2006 Christophe Leitienne+ * Copyright 2008 David Hoerl+ */++#include <stdint.h>++#ifndef XLS_TYPES_INC+#define XLS_TYPES_INC++#pragma pack(1)++typedef unsigned char		BYTE;//  __attribute__ ((aligned (1)));	// 1 bytes+typedef uint16_t			WORD;// __attribute__ ((aligned (1)));	// 2 bytes+typedef uint32_t			DWORD;//  __attribute__ ((aligned (1)));	// 4 bytes++#endif
+ libxls-0.3.0_pre107.tar.bz2 view

binary file changed (absent → 294219 bytes)

+ libxls.cabal view
@@ -0,0 +1,40 @@+-- Initial libxls.cabal generated by cabal init.  For further +-- documentation, see http://haskell.org/cabal/users-guide/++name:                libxls+version:             0.2+synopsis:            Bindings to libxls+description:         Read Data From xls file +license:             MIT         +license-file:        LICENSE+author:              uuhan+maintainer:          xuminhui189@gmail.com+-- copyright:           +category:            FFI+build-type:          Custom+extra-source-files:  libxls-0.3.0_pre107.tar.bz2+                     README+cabal-version:       >=1.10+library+  hs-source-dirs:      src+  include-dirs:        include+  exposed-modules:     Data.Libxls.Reader +                     , Bindings.Xls+                     , Bindings.Ole+                     , Bindings.Xlsstruct+                     , Bindings.Xlstool+                     , Bindings.Xlstypes++  build-depends:       base >=4.8 && <4.9+                     , bindings-DSL++  build-tools:         hsc2hs+  default-language:    Haskell2010+  default-extensions:  ForeignFunctionInterface++  install-includes:    brdb.c.h brdb.h ole.h xls.h xlsstruct.h xlstool.h xlstypes.h+++source-repository head+    type: git+    location: https://github.com/uuhan/bindings-libxls
+ src/Bindings/Ole.hsc view
@@ -0,0 +1,167 @@+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+#include <bindings.dsl.h>+#include "ole.h"+module Bindings.Ole where+import Foreign.Ptr+#strict_import++import Bindings.Xlstypes+{- typedef struct TIME_T {+            DWORD LowDate; DWORD HighDate;+        } TIME_T; -}+#starttype struct TIME_T+#field LowDate , CUInt+#field HighDate , CUInt+#stoptype+{- typedef struct OLE2Header {+            DWORD id[2];+            DWORD clid[4];+            WORD verminor;+            WORD verdll;+            WORD byteorder;+            WORD lsectorB;+            WORD lssectorB;+            WORD reserved1;+            DWORD reserved2;+            DWORD reserved3;+            DWORD cfat;+            DWORD dirstart;+            DWORD reserved4;+            DWORD sectorcutoff;+            DWORD sfatstart;+            DWORD csfat;+            DWORD difstart;+            DWORD cdif;+            DWORD MSAT[109];+        } OLE2Header; -}+#starttype struct OLE2Header+#array_field id , CUInt+#array_field clid , CUInt+#field verminor , CUShort+#field verdll , CUShort+#field byteorder , CUShort+#field lsectorB , CUShort+#field lssectorB , CUShort+#field reserved1 , CUShort+#field reserved2 , CUInt+#field reserved3 , CUInt+#field cfat , CUInt+#field dirstart , CUInt+#field reserved4 , CUInt+#field sectorcutoff , CUInt+#field sfatstart , CUInt+#field csfat , CUInt+#field difstart , CUInt+#field cdif , CUInt+#array_field MSAT , CUInt+#stoptype+{- typedef struct {+            char * name; DWORD start; DWORD size;+        } st_olefiles_data; -}+#starttype st_olefiles_data+#field name , CString+#field start , CUInt+#field size , CUInt+#stoptype+{- typedef struct st_olefiles {+            long count; st_olefiles_data * file;+        } st_olefiles; -}+#starttype struct st_olefiles+#field count , CLong+#field file , Ptr <st_olefiles_data>+#stoptype+{- typedef struct OLE2 {+            FILE * file;+            WORD lsector;+            WORD lssector;+            DWORD cfat;+            DWORD dirstart;+            DWORD sectorcutoff;+            DWORD sfatstart;+            DWORD csfat;+            DWORD difstart;+            DWORD cdif;+            DWORD * SecID;+            DWORD * SSecID;+            BYTE * SSAT;+            st_olefiles files;+        } OLE2; -}+#opaque_t _IO_FILE+#starttype struct OLE2+#field file , Ptr <struct _IO_FILE>+#field lsector , CUShort+#field lssector , CUShort+#field cfat , CUInt+#field dirstart , CUInt+#field sectorcutoff , CUInt+#field sfatstart , CUInt+#field csfat , CUInt+#field difstart , CUInt+#field cdif , CUInt+#field SecID , Ptr CUInt+#field SSecID , Ptr CUInt+#field SSAT , Ptr CUChar+#field files , <struct st_olefiles>+#stoptype+{- typedef struct OLE2Stream {+            OLE2 * ole;+            DWORD start;+            DWORD pos;+            int cfat;+            int size;+            DWORD fatpos;+            BYTE * buf;+            DWORD bufsize;+            BYTE eof;+            BYTE sfat;+        } OLE2Stream; -}+#starttype struct OLE2Stream+#field ole , Ptr <struct OLE2>+#field start , CUInt+#field pos , CUInt+#field cfat , CInt+#field size , CInt+#field fatpos , CUInt+#field buf , Ptr CUChar+#field bufsize , CUInt+#field eof , CUChar+#field sfat , CUChar+#stoptype+{- typedef struct PSS {+            BYTE name[64];+            WORD bsize;+            BYTE type;+            BYTE flag;+            DWORD left;+            DWORD right;+            DWORD child;+            WORD guid[8];+            DWORD userflags;+            TIME_T time[2];+            DWORD sstart;+            DWORD size;+            DWORD proptype;+        } PSS; -}+#starttype struct PSS+#array_field name , CUChar+#field bsize , CUShort+#field type , CUChar+#field flag , CUChar+#field left , CUInt+#field right , CUInt+#field child , CUInt+#array_field guid , CUShort+#field userflags , CUInt+#array_field time , <struct TIME_T>+#field sstart , CUInt+#field size , CUInt+#field proptype , CUInt+#stoptype+#ccall ole2_read , Ptr () -> CLong -> CLong -> Ptr <struct OLE2Stream> -> IO CInt+#ccall ole2_sopen , Ptr <struct OLE2> -> CUInt -> CInt -> IO (Ptr <struct OLE2Stream>)+#ccall ole2_seek , Ptr <struct OLE2Stream> -> CUInt -> IO ()+#ccall ole2_fopen , Ptr <struct OLE2> -> CString -> IO (Ptr <struct OLE2Stream>)+#ccall ole2_fclose , Ptr <struct OLE2Stream> -> IO ()+#ccall ole2_open , CString -> CString -> IO (Ptr <struct OLE2>)+#ccall ole2_close , Ptr <struct OLE2> -> IO ()+#ccall ole2_bufread , Ptr <struct OLE2Stream> -> IO ()
+ src/Bindings/Xls.hsc view
@@ -0,0 +1,23 @@+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+#include <bindings.dsl.h>+#include "xls.h"+module Bindings.Xls where+import Foreign.Ptr+import Bindings.Xlsstruct+#strict_import++import Bindings.Xlstool+#ccall xls_getVersion , IO CString+#globalvar xls_debug , CInt+#ccall xls , IO CInt+#ccall xls_addSST , Ptr <xlsWorkBook> -> Ptr <SST> -> CUInt -> IO ()+#ccall xls_appendSST , Ptr <xlsWorkBook> -> Ptr CUChar -> CUInt -> IO ()+#ccall xls_addFormat , Ptr <xlsWorkBook> -> Ptr <FORMAT> -> IO ()+#ccall xls_parseWorkBook , Ptr <xlsWorkBook> -> IO ()+#ccall xls_parseWorkSheet , Ptr <xlsWorkSheet> -> IO ()+#ccall xls_open , CString -> CString -> IO (Ptr <xlsWorkBook>)+#ccall xls_close_WB , Ptr <xlsWorkBook> -> IO ()+#ccall xls_getWorkSheet , Ptr <xlsWorkBook> -> CInt -> IO (Ptr <xlsWorkSheet>)+#ccall xls_close_WS , Ptr <xlsWorkSheet> -> IO ()+#ccall xls_row , Ptr <xlsWorkSheet> -> CUShort -> IO (Ptr <st_row_data>)+#ccall xls_cell , Ptr <xlsWorkSheet> -> CUShort -> CUShort -> IO (Ptr <st_cell_data>)
+ src/Bindings/Xlsstruct.hsc view
@@ -0,0 +1,314 @@+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+#include <bindings.dsl.h>+#include "xlsstruct.h"+module Bindings.Xlsstruct where+import Foreign.Ptr+import Bindings.Ole+#strict_import++#starttype BOF+#field id , CUShort+#field size , CUShort+#stoptype+#starttype BIFF+#field ver , CUShort+#field type , CUShort+#field id_make , CUShort+#field year , CUShort+#field flags , CUInt+#field min_ver , CUInt+#array_field buf , CUChar+#stoptype+#starttype WIND1+#field xWn , CUShort+#field yWn , CUShort+#field dxWn , CUShort+#field dyWn , CUShort+#field grbit , CUShort+#field itabCur , CUShort+#field itabFirst , CUShort+#field ctabSel , CUShort+#field wTabRatio , CUShort+#stoptype+{- #starttype BOUNDSHEET -}+{- #field filepos , CUInt -}+{- #field type , CUChar -}+{- #field visible , CUChar -}+{- #array_field name , CUChar -}+{- #stoptype -}+#starttype ROW+#field index , CUShort+#field fcell , CUShort+#field lcell , CUShort+#field height , CUShort+#field notused , CUShort+#field notused2 , CUShort+#field flags , CUShort+#field xf , CUShort+#stoptype++#starttype COL+#field row , CUShort+#field col , CUShort+#field xf , CUShort+#stoptype++{- #starttype FORMULA -}+{- #field row , CUShort -}+{- #field col , CUShort -}+{- #field xf , CUShort -}+{- #field resid , CUChar -}+{- #array_field resdata , CUChar -}+{- #field res , CUShort -}+{- #field flags , CUShort -}+{- #array_field chn , CUChar -}+{- #field len , CUShort -}+{- #array_field value , CUChar -}+{- #stoptype -}++{- #starttype RK -}+{- #field row , CUShort -}+{- #field col , CUShort -}+{- #field xf , CUShort -}+{- #array_field value , CUChar -}+{- #stoptype -}++{- #starttype LABELSST -}+{- #field row , CUShort -}+{- #field col , CUShort -}+{- #field xf , CUShort -}+{- #array_field value , CUChar -}+{- #stoptype -}++#starttype BLANK+#field row , CUShort+#field col , CUShort+#field xf , CUShort+#stoptype++{- #starttype LABEL -}+{- #field row , CUShort -}+{- #field col , CUShort -}+{- #field xf , CUShort -}+{- #array_field value , CUChar -}+{- #stoptype -}++#starttype SST+#field num , CUInt+#field numofstr , CUInt+#field strings , CUChar+#stoptype+{- #starttype XF5 -}+{- #field font , CUShort -}+{- #field format , CUShort -}+{- #field type , CUShort -}+{- #field align , CUShort -}+{- #field color , CUShort -}+{- #field fill , CUShort -}+{- #field border , CUShort -}+{- #field linestyle , CUShort -}+{- #stoptype -}+#starttype XF8+#field font , CUShort+#field format , CUShort+#field type , CUShort+#field align , CUChar+#field rotation , CUChar+#field ident , CUChar+#field usedattr , CUChar+#field linestyle , CUInt+#field linecolor , CUInt+#field groundcolor , CUShort+#stoptype+{- #starttype BR_NUMBER -}+{- #field row , CUShort -}+{- #field col , CUShort -}+{- #field xf , CUShort -}+{- #field value , CDouble -}+{- #stoptype -}+{- #starttype COLINFO -}+{- #field first , CUShort -}+{- #field last , CUShort -}+{- #field width , CUShort -}+{- #field xf , CUShort -}+{- #field flags , CUShort -}+{- #field notused , CUShort -}+{- #stoptype -}+{- #starttype MERGEDCELLS -}+{- #field rowf , CUShort -}+{- #field rowl , CUShort -}+{- #field colf , CUShort -}+{- #field coll , CUShort -}+{- #stoptype -}+{- #starttype FONT -}+{- #field height , CUShort -}+{- #field flag , CUShort -}+{- #field color , CUShort -}+{- #field bold , CUShort -}+{- #field escapement , CUShort -}+{- #field underline , CUChar -}+{- #field family , CUChar -}+{- #field charset , CUChar -}+{- #field notused , CUChar -}+{- #field name , CUChar -}+{- #stoptype -}+#starttype FORMAT+#field index , CUShort+#array_field value , CUChar+#stoptype+#starttype st_sheet_data+#field filepos , CUInt+#field visibility , CUChar+#field type , CUChar+#field name , CString+#stoptype+#starttype st_sheet+#field count , CUInt+#field sheet , Ptr <st_sheet_data>+#stoptype+#starttype st_font_data+#field height , CUShort+#field flag , CUShort+#field color , CUShort+#field bold , CUShort+#field escapement , CUShort+#field underline , CUChar+#field family , CUChar+#field charset , CUChar+#field name , CString+#stoptype+#starttype st_font+#field count , CUInt+#field font , Ptr <st_font_data>+#stoptype+#starttype st_format_data+#field index , CUShort+#field value , CString+#stoptype+#starttype st_format+#field count , CUInt+#field format , Ptr <st_format_data>+#stoptype++#starttype st_xf_data+#field font , CUShort+#field format , CUShort+#field type , CUShort+#field align , CUChar+#field rotation , CUChar+#field ident , CUChar+#field usedattr , CUChar+#field linestyle , CUInt+#field linecolor , CUInt+#field groundcolor , CUShort+#stoptype++#starttype st_xf+#field count , CUInt+#field xf , <st_xf_data>+#stoptype++#starttype str_sst_string+#field str , CString+#stoptype++#starttype st_sst+#field count , CUInt+#field lastid , CUInt+#field continued , CUInt+#field lastln , CUInt+#field lastrt , CUInt+#field lastsz , CUInt+#field string , Ptr <str_sst_string>+#stoptype++#starttype st_cell_data+#field id , CUShort+#field row , CUShort+#field col , CUShort+#field xf , CUShort+#field d , CDouble+#field l , CLong+#field str , CString+#field ishiden , CUChar+#field width , CUShort+#field colspan , CUShort+#field rowspan , CUShort+#stoptype++#starttype st_cell+#field count , CUInt+#field cell , Ptr <st_cell_data>+#stoptype++#starttype st_row_data+#field index , CUShort+#field fcell , CUShort+#field lcell , CUShort+#field height , CUShort+#field flags , CUShort+#field xf , CUShort+#field xfflags , CUChar+#field cells , <st_cell>+#stoptype++#starttype st_row+#field lastcol , CUShort+#field lastrow , CUShort+#field row , Ptr <st_row_data>+#stoptype++#starttype st_colinfo_data+#field first , CUShort+#field last , CUShort+#field width , CUShort+#field xf , CUShort+#field flags , CUShort+#stoptype++#starttype st_colinfo+#field count , CUInt+#field col , Ptr <st_colinfo_data>+#stoptype++#starttype xlsWorkBook+#field olestr , Ptr <struct OLE2Stream>+#field filepos , CLong+#field is5ver , CUChar+#field type , CUShort+#field codepage , CUShort+#field charset , CString+#field sheets , <st_sheet>+#field sst , <st_sst>+#field xfs , <st_xf>+#field fonts , <st_font>+#field formats , <st_format>+#field summary , CString+#field docSummary , CString+#stoptype++#starttype xlsWorkSheet+#field filepos , CUInt+#field defcolwidth , CUShort+#field rows , <st_row>+#field workbook , Ptr <xlsWorkBook>+#field colinfo , <st_colinfo>+#field maxcol , CUShort+#stoptype++#synonym_t xlsCell , <st_cell_data>++#synonym_t xlsRow , <st_row_data>++#starttype xlsSummaryInfo+#field title , CString+#field subject , CString+#field author , CString+#field keywords , CString+#field comment , CString+#field lastAuthor , CString+#field appName , CString+#field category , CString+#field manager , CString+#field company , CString+#stoptype
+ src/Bindings/Xlstool.hsc view
@@ -0,0 +1,24 @@+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+#include <bindings.dsl.h>+#include "xlstool.h"+module Bindings.Xlstool where+import Foreign.Ptr+#strict_import++import Bindings.Xlsstruct+{- #globalvar colors , CUInt -}+#ccall dumpbuf , CString -> CLong -> Ptr CUChar -> IO ()+#ccall verbose , CString -> IO ()+#ccall unicode_decode , Ptr CUChar -> CInt -> Ptr CInt -> CString -> IO CString+#ccall get_string , Ptr CUChar -> CUChar -> CUChar -> CString -> IO CString+#ccall xls_getColor , CUShort -> CUShort -> IO CUInt+#ccall xls_showBookInfo , Ptr <xlsWorkBook> -> IO ()+#ccall xls_showROW , Ptr <st_row_data> -> IO ()+#ccall xls_showColinfo , Ptr <st_colinfo_data> -> IO ()+#ccall xls_showCell , Ptr <st_cell_data> -> IO ()+#ccall xls_showFont , Ptr <st_font_data> -> IO ()+#ccall xls_showXF , Ptr <XF8> -> IO ()+#ccall xls_showFormat , Ptr <st_format_data> -> IO ()+#ccall xls_getfcell , Ptr <xlsWorkBook> -> Ptr <st_cell_data> -> IO CString+#ccall xls_getCSS , Ptr <xlsWorkBook> -> IO CString+#ccall xls_showBOF , Ptr <BOF> -> IO ()
+ src/Bindings/Xlstypes.hsc view
@@ -0,0 +1,13 @@+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+#include <bindings.dsl.h>+#include "xlstypes.h"+module Bindings.Xlstypes where+import Foreign.Ptr+#strict_import++{- typedef unsigned char BYTE; -}+#synonym_t BYTE , CUChar+{- typedef uint16_t WORD; -}+#synonym_t WORD , CUShort+{- typedef uint32_t DWORD; -}+#synonym_t DWORD , CUInt
+ src/Data/Libxls/Reader.hs view
@@ -0,0 +1,43 @@+module Data.Libxls.Reader where++import Bindings.Xls+import Bindings.Xlsstruct+import Bindings.Xlstool++import Foreign.Ptr+import Foreign.C.String+import Foreign.C.Types+import Foreign.C.Error++type WorkBook = Ptr C'xlsWorkBook+type WorkSheet = Ptr C'xlsWorkSheet+type Cells = Ptr C'st_cell+type CellData = Ptr C'st_cell_data++openBook :: String -> String -> IO WorkBook+openBook name e = do+    withCString name $ \c'name -> do+        withCString e $ \c'decode -> do+            throwErrnoIfNull ("Open " ++ name ++ "Failed!")+                (do +                    wb <- c'xls_open c'name c'decode+                    c'xls_parseWorkBook wb+                    return wb+                    )++openSheet :: WorkBook -> Int -> IO WorkSheet+openSheet book no = do+    throwErrnoIfNull "No Such Sheet" $ +        (do +            st <- c'xls_getWorkSheet book (fromIntegral no)+            c'xls_parseWorkSheet st+            return st+            )++getCell :: WorkSheet -> Int -> Int -> IO CellData+getCell sheet x y = do+    throwErrnoIfNull "No Such Cell" $ +        c'xls_cell sheet (fromIntegral x) (fromIntegral y)++showCellInfo :: CellData -> IO ()+showCellInfo c = c'xls_showCell c