Author: miguel
Date: 2008-02-11 02:14:37 -0500 (Mon, 11 Feb 2008)
New Revision: 95419

Added:
   trunk/wahid/Cell.cs
   trunk/wahid/DirAccess.cs
   trunk/wahid/Locale.cs
   trunk/wahid/Makefile
   trunk/wahid/README
   trunk/wahid/Sheet.cs
   trunk/wahid/Value.cs
   trunk/wahid/Workbook.cs
   trunk/wahid/ZipAccess.cs
   trunk/wahid/main.cs
   trunk/wahid/xlsx.cs
Log:
Add

Added: trunk/wahid/Cell.cs
===================================================================
--- trunk/wahid/Cell.cs 2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/Cell.cs 2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,50 @@
+//
+// Cell.cs
+//
+// Authors:
+//   Miguel de Icaza ([EMAIL PROTECTED])
+//
+// Copyright 2008 Novell, Inc (http://www.novell.com).
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace Wahid {
+
+       public class Cell {
+               public Sheet Sheet { get; private set; }
+
+               public int Col { get; set; }
+               public int Row { get; set; }
+
+               /// <summary>
+               ///   Internal constructor, must only be called by 
Sheet.CreateCell
+               /// </summary>
+               public Cell (Sheet sheet, int col, int row) 
+               {
+                       Sheet = sheet;
+                       Col = col;
+                       Row = row;
+
+                       Console.WriteLine ("Creating cell {0} {1}", row, col);
+               }
+       }
+}
\ No newline at end of file


Property changes on: trunk/wahid/Cell.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/wahid/DirAccess.cs
===================================================================
--- trunk/wahid/DirAccess.cs    2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/DirAccess.cs    2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,45 @@
+//
+// DirAccess.cs: primitive access to zip files, it must be unpacked.
+//
+// Authors:
+//   Miguel de Icaza ([EMAIL PROTECTED])
+//
+// Copyright 2008 Novell, Inc (http://www.novell.com).
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IO;
+using System;
+
+namespace Wahid {
+       public class DirAccess : ZipAccess {
+               string loc;
+               
+               public DirAccess (string loc)
+               {
+                       this.loc = loc;
+               }
+               
+               public override Stream Get (string resource)
+               {
+                       return File.OpenRead (Path.Combine (loc, resource));
+               }
+       }
+}
\ No newline at end of file


Property changes on: trunk/wahid/DirAccess.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/wahid/Locale.cs
===================================================================
--- trunk/wahid/Locale.cs       2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/Locale.cs       2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,13 @@
+namespace Wahid {
+
+       static class Helper {
+
+               /// <summary>
+               ///   Allows C-like _("string") localization
+               /// </summary>
+               public static string _ (this object s)
+               {
+                       return s.ToString ();
+               }
+       }
+}


Property changes on: trunk/wahid/Locale.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/wahid/Makefile
===================================================================
--- trunk/wahid/Makefile        2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/Makefile        2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,9 @@
+SOURCES = Cell.cs Locale.cs Sheet.cs Workbook.cs ZipAccess.cs Value.cs xlsx.cs 
+
+DESKTOP_SOURCES = DirAccess.cs 
+
+wahid.exe: main.cs $(SOURCES) $(DESKTOP_SOURCES) Makefile
+       gmcs -debug -out:wahid.exe main.cs $(SOURCES) $(DESKTOP_SOURCES) 
-r:System.Xml.Linq -r:System.Core
+
+run: wahid.exe
+       mono --debug wahid.exe
\ No newline at end of file


Property changes on: trunk/wahid/Makefile
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/wahid/README
===================================================================
--- trunk/wahid/README  2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/README  2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,44 @@
+Wahid - A Spreadsheet engine
+----------------------------
+
+       This is spreadsheet engine, initially without a GUI.
+
+       Ideally a number of user interfaces can be built on top of the
+       spreadsheet engine: 
+
+           * Silverlight (like Google's spreadsheets)
+
+           * gui.cs (the most powerful and awesome RIA in the world)
+
+           * command-line, to compute, and convert data.
+
+           * Gnome (worth doing?)
+
+OOXML
+-----
+
+       Am drawing inspiration form the OOXML specification on how to
+       structure the internals of this engine, but the idea is to
+       have multiple importers and expoters.
+
+       Currently the code does not even unzip archives, it expects a
+       directory called "test" to contain an unzipped OOXML file (I
+       used the gnumeric test files for this).
+
+       The Zip support is split from the loader as in Silverlight we
+       would want to use the Downloader class to unzip the files for
+       us, while on the desktop we can use SharpZipLib. 
+
+Models and Views
+----------------
+
+       The engine will communicate with the views through events that
+       the views connect to.  
+
+       In addition to the usual support for views for multiple
+       spreadsheets, this will be useful to have views and
+       controllers that can be connected on the backend to a server.
+       This would allow multiple users to edit the spreadsheet
+       simultaneously. 
+
+       
\ No newline at end of file

Added: trunk/wahid/Sheet.cs
===================================================================
--- trunk/wahid/Sheet.cs        2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/Sheet.cs        2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,61 @@
+//
+// Cell.cs
+//
+// Authors:
+//   Miguel de Icaza ([EMAIL PROTECTED])
+//
+// Copyright 2008 Novell, Inc (http://www.novell.com).
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace Wahid {
+
+       public class Sheet {
+               public string Name;
+               public int Id;
+               
+               public Sheet (string name, int id)
+               {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+
+                       this.Name = name;
+                       this.Id = id;
+               }
+               
+
+               public Cell CreateCell (int col, int row)
+               {
+                       var cell = new Cell (this, col, row);
+
+                       Attach (cell);
+                       
+                       return cell;
+               }
+
+               public void Attach (Cell cell)
+               {
+                       
+               }
+       }
+}
+


Property changes on: trunk/wahid/Sheet.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/wahid/Value.cs
===================================================================
--- trunk/wahid/Value.cs        2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/Value.cs        2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,67 @@
+//
+// Value.cs
+//
+// Authors:
+//   Miguel de Icaza ([EMAIL PROTECTED])
+//
+// Copyright 2008 Novell, Inc (http://www.novell.com).
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace Wahid {
+
+       public class Value {
+       }
+
+       public class BoolValue : Value {
+               public bool Value;
+               
+               public BoolValue (bool v)
+               {
+                       this.Value = v;
+               }
+       }
+
+       public class ErrorValue : Value {
+               public ErrorValue ()
+               {
+               }
+               
+       }
+
+       public class StringValue : Value {
+               public string Value;
+               
+               public StringValue (string v)
+               {
+                       this.Value = v;
+               }
+       }
+
+       public class NumberValue : Value {
+               public double Value;
+
+               public NumberValue (double v)
+               {
+                       Value = v;
+               }
+       }
+}
\ No newline at end of file


Property changes on: trunk/wahid/Value.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/wahid/Workbook.cs
===================================================================
--- trunk/wahid/Workbook.cs     2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/Workbook.cs     2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,61 @@
+//
+// Workbook.cs
+//
+// Authors:
+//   Miguel de Icaza ([EMAIL PROTECTED])
+//
+// Copyright 2008 Novell, Inc (http://www.novell.com).
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+
+namespace Wahid {
+
+       public class Workbook {
+
+               public bool Dirty { get; set; }
+
+               public Dictionary<int,Sheet> Sheets { get; private set; }
+               
+               public Workbook () : this (0)
+               {
+               }
+
+               public Workbook (int sheets) 
+               {
+                       Sheets = new Dictionary<int,Sheet> ();
+                       
+                       for (int i = 0; i < sheets; i++){
+                               //var s = new Sheet (String.Format (_("Sheet 
{0}"), i));
+                       }
+               }
+
+               public Sheet CreateSheet (string name, int id)
+               {
+                       if (Sheets.ContainsKey (id))
+                               throw new ArgumentException ("Workbook already 
contains sheet with this id", "id");
+
+                       return Sheets [id] = new Sheet (name, id);
+               }
+       }
+}
+


Property changes on: trunk/wahid/Workbook.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/wahid/ZipAccess.cs
===================================================================
--- trunk/wahid/ZipAccess.cs    2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/ZipAccess.cs    2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,17 @@
+using System;
+using System.IO;
+
+namespace Wahid {
+
+       //
+       // A simple wrapper, so we can have multiple loaders later
+       //
+       public abstract class ZipAccess {
+
+               public ZipAccess ()
+               {
+               }
+
+               public abstract Stream Get (string resource);
+       }
+}


Property changes on: trunk/wahid/ZipAccess.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/wahid/main.cs
===================================================================
--- trunk/wahid/main.cs 2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/main.cs 2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,14 @@
+using System;
+using Wahid;
+using Wahid.OOXML;
+
+class Test {
+       static void Main ()
+       {
+               Xlsx xlsx = Xlsx.Load ("test");
+               if (xlsx.Error == null)
+                       Console.WriteLine ("Success");
+               else
+                       Console.WriteLine ("Result: " + xlsx.Error);
+       }
+}
\ No newline at end of file


Property changes on: trunk/wahid/main.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/wahid/xlsx.cs
===================================================================
--- trunk/wahid/xlsx.cs 2008-02-11 07:06:39 UTC (rev 95418)
+++ trunk/wahid/xlsx.cs 2008-02-11 07:14:37 UTC (rev 95419)
@@ -0,0 +1,249 @@
+//
+// xlsx.cs: Support for loading OOXML spreadsheets
+//
+// Authors:
+//   Miguel de Icaza ([EMAIL PROTECTED])
+//
+// Copyright 2008 Novell, Inc (http://www.novell.com).
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.Generic;
+
+using System.Linq;
+using System.Xml;
+using System.Xml.Linq;
+using System.Xml.XPath;
+
+
+using System.Reflection;
+
+namespace Wahid.OOXML {
+
+       public class LoadException : Exception {
+               public LoadException (string msg) : base (msg) {}
+       }
+       
+       public class Relationship {
+               public enum RType {
+                       SharedStrings,
+                       Worksheet,
+                       Styles,
+                       Theme,
+                       CalcChain,
+                       Unknown
+               }
+
+               public string Id;
+               public string Target;
+               public RType  Type;
+
+               public static RType Lookup (string s)
+               {
+                       switch (s){
+                       case 
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings":
+                               return RType.SharedStrings;
+                       case 
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":
+                               return RType.Worksheet;
+                       case 
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles":
+                               return RType.Styles;
+                       case 
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme":
+                               return RType.Theme;
+                       case 
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain":
+                               return RType.CalcChain;
+                       }
+                       return RType.Unknown;
+               }
+               
+               public Relationship (RType type, string id, string target)
+               {
+                       Id = id;
+                       Target = target;
+                       Type = type;
+               }
+               
+       }
+
+       public class OOXML {
+               
+       }
+       
+       public class Xlsx {
+               static XNamespace ns_workbook = 
"http://schemas.openxmlformats.org/spreadsheetml/2006/main";;
+               static XNamespace ns_rels = 
"http://schemas.openxmlformats.org/officeDocument/2006/relationships";;
+
+               static XName xnc     = "c";
+               static XName xnr     = "r";
+               static XName xns     = "s";
+               static XName xnt     = "t";
+
+               public Workbook Workbook { get; private set; }
+               public string Error { get; private set; }
+
+               Dictionary<string,Relationship> relationships;
+               
+               ZipAccess loader;
+
+               public static Xlsx Load (string filename)
+               {
+                       Xlsx x = new Xlsx (new DirAccess (filename));
+
+                       x.Load ();
+
+#if false
+                       try {
+                       } catch (Exception e){
+                               if (x.Error == null)
+                                       x.Error = "Generic loading error";
+                               x.Error += e;
+                               x.Workbook = null;
+                       }
+#endif
+       
+                       return x;
+               }
+               
+               Xlsx (ZipAccess loader)
+               {
+                       Workbook = new Workbook ();
+                       this.loader = loader;
+                       Error = null;
+               }
+
+               TextReader Get (string part)
+               {
+                       try {
+                               return new StreamReader (loader.Get (part));
+                       } catch {
+                               Error = "Failure to retrieve part " + part;
+                               throw new LoadException (Error);
+                       }
+               }
+
+               class Dingus {
+                       public Dingus (string s)
+                       {
+                               Console.WriteLine (s);
+                       }
+               }
+               
+               void LoadRelationships ()
+               {
+                       relationships = new Dictionary<string,Relationship> ();
+                       
+                       XElement xrel = XElement.Load (Get 
("xl/_rels/workbook.xml.rels"));
+
+                       var x = 
+                               from rel in xrel.Elements ()
+                               let type = Relationship.Lookup ((string) 
rel.Attribute ("Type"))
+                               where type != Relationship.RType.Unknown
+                               select new Relationship (type,
+                                                        (string) rel.Attribute 
("Id"),
+                                                        (string) rel.Attribute 
("Target"));
+                       relationships = x.ToDictionary (f => f.Id);
+               }
+
+               void ParseReference (string s, out int col, out int row)
+               {
+                       col = 0;
+                       row = 0;
+                       
+                       foreach (char c in s){
+                               if (c >= 'A' && c <= 'Z'){
+                                       col = col * 26 + ((int) c) - 'A';
+                               } else {
+                                       row = row * 10 + ((int) c - '0');
+                               }
+                       }
+               }
+               
+               void LoadSheetData (Sheet sheet, XElement xsheetData)
+               {
+                       // <row>
+                       foreach (XElement xrow in xsheetData.Elements ()){
+                               int row = Int32.Parse ((string) xrow.Attribute 
("r"));
+
+                               // <c> 
+                               foreach (XElement xcell in xrow.Elements ()){
+                                       int cell_col, cell_row;
+                                       
+                                       ParseReference ((string) 
xcell.Attribute (xnr), out cell_col, out cell_row);
+
+                                       if (row != cell_row){
+                                               // this should not happen
+
+                                               Error = "Document contains cell 
references outside of their row";
+                                               throw new Exception ();
+                                       }
+                                       
+                                       Cell cell = sheet.CreateCell (cell_col, 
cell_row);
+
+                                       string type = (string) xcell.Attribute 
(xnt);
+
+                                       //
+                                       // HERE:
+                                       //
+                                       // Parse type of cell, get data from 
the cell, put that inside
+                                       // the cell
+                                       //
+                               }
+                       }
+               }
+                               
+               void LoadSheet (Sheet sheet, XElement xsheet)
+               {
+                       XName xcols = ns_workbook + "cols";
+                       XName xsheetData = ns_workbook + "sheetData";
+
+                       foreach (XElement se in xsheet.Elements ()){
+                               if (se.Name == xsheetData)
+                                       LoadSheetData (sheet, se);
+                       }
+               }
+               
+               void LoadWorkbook ()
+               {
+                       XElement xwork = XElement.Load (Get 
("xl/workbook.xml"));
+                       
+                       // Since Linq.XPath is not working, work around it
+                       var sheets_and_sources = from l in xwork.Elements ()
+                               let xsheets = ns_workbook + "sheets"
+                               let xrid = ns_rels + "id"
+                               where l.Name == xsheets
+                               from s in l.Elements ()
+                                 let rtarget = relationships [(string) 
s.Attribute (xrid)].Target
+                                 let sheet = Workbook.CreateSheet 
((string)s.Attribute ("name"),
+                                                                   (int) 
s.Attribute ("sheetId"))
+                                 select new { sheet, rtarget } ;
+
+                       foreach (var ss in sheets_and_sources)
+                               LoadSheet (ss.sheet, XElement.Load (Get ("xl/" 
+ ss.rtarget)));
+               }
+               
+               void Load ()
+               {
+                       LoadRelationships ();
+                       // LoadStyle ();
+                       LoadWorkbook ();
+               }
+       }
+}
\ No newline at end of file


Property changes on: trunk/wahid/xlsx.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to