public static XmlWorkSheet operator +(XmlWorkSheet a, XmlWorkSheet b) { XmlWorkSheet c = new XmlWorkSheet(); c.Table = a.Table + b.Table; return(c); }
/// <summary> ///XMl Serialiaztion /// </summary> /// <param name="The File Path on disk"></param> /// <param name="Double list datas"></param> /// <returns></returns> public static bool XmlSerialiaztion(string sFilePath, List <List <string> > llString) { try { XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces(); xmlns.Add("", "urn:schemas-microsoft-com:office:spreadsheet"); xmlns.Add("o", "urn:schemas-microsoft-com:office:office"); xmlns.Add("x", "urn:schemas-microsoft-com:office:excel"); xmlns.Add("ss", "urn:schemas-microsoft-com:office:spreadsheet"); xmlns.Add("html", "http://www.w3.org/TR/REC-html40"); List <Row> lXRow = new List <Row>(); foreach (List <string> ls in llString) { List <Cell> lXCell = new List <Cell>(); foreach (string s in ls) { Data xData = new Data(s); Cell xCell = new Cell(xData); lXCell.Add(xCell); } Row xRow = new Row(lXCell); lXRow.Add(xRow); } XmlTable Table = new XmlTable(lXRow); XmlWorkSheet xWorkSheet = new XmlWorkSheet(Table); Workbook xWorkBook = new Workbook(xmlns, xWorkSheet); Stream sFileSteam = new FileStream(sFilePath, FileMode.Create, FileAccess.ReadWrite); XmlWriterSettings xmlSet = new XmlWriterSettings(); XmlSerializer xmlserial = new XmlSerializer(typeof(Workbook)); xmlserial.Serialize(sFileSteam, xWorkBook, xmlns); string sXml = "\r\n" + "<?mso-application progid=\"Excel.Sheet\"?>"; FileStreamInsert(sFileSteam, sXml, 21); sFileSteam.Flush(); sFileSteam.Close(); return(true); } catch (Exception ex) { MessageBox.Show("XmlSerialiaztion error: " + ex.Message); return(false); } }
public Workbook(XmlSerializerNamespaces xmlns, XmlWorkSheet xWorkSheet) { this._xmlns = xmlns; this._xWorkSheet = xWorkSheet; }