/// <summary> /// Create workbook.xml /// </summary> private void Create_WB_fromDS(DataSet ds, string fileName) { if (string.IsNullOrEmpty(fileName) || ds == null) { return; } if (ds.Tables.Count < 1) { return; } string header_str = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" + HssStr.WinNextLine + "<workbook xmlns='http://schemas.openxmlformats.org/spreadsheetml/2006/main' " + HssStr.WinNextLine + "xmlns:r='http://schemas.openxmlformats.org/officeDocument/2006/relationships'><sheets>" + HssStr.WinNextLine; FileStream fs = new FileStream(fileName, FileMode.Create); byte[] header_bts = Encoding.UTF8.GetBytes(header_str); fs.Write(header_bts, 0, header_bts.Length); for (int i = 1; i <= ds.Tables.Count; ++i) { DataTable dt = ds.Tables[i - 1]; string str = "<sheet name=\"" + HssStr.ToSafeXML_str(dt.TableName) + "\" sheetId='" + i + "' r:id='hssSheet" + i + "'/>" + HssStr.WinNextLine; byte[] arr = Encoding.UTF8.GetBytes(str); fs.Write(arr, 0, arr.Length); ++this.hLog.RecordNum; } byte[] tail_bts = Encoding.UTF8.GetBytes("</sheets></workbook>"); fs.Write(tail_bts, 0, tail_bts.Length); fs.Close(); }
public string ToXML() { StringBuilder sb = new StringBuilder(); sb.Append("<col Hidden='").Append(this.hidden_flag).Append("'>"); sb.Append(HssStr.ToSafeXML_str(this.column_key)).Append("</col>"); return(sb.ToString()); }
public string GetXML() { StringBuilder sb = new StringBuilder("<EVENT_INFORMATION>").Append(HssStr.WinNextLine); sb.Append("<UniqueUniversalEventIdentifier>").Append(this.UniqueUniversalEventIdentifier).Append("</UniqueUniversalEventIdentifier>").Append(HssStr.WinNextLine); sb.Append("<SECURITY_IDENTIFIER_CUSIP>").Append(this.SECURITY_IDENTIFIER_CUSIP).Append("</SECURITY_IDENTIFIER_CUSIP>").Append(HssStr.WinNextLine); sb.Append("<ISSUER_NAME>").Append(HssStr.ToSafeXML_str(this.ISSUER_NAME)).Append("</ISSUER_NAME>").Append(HssStr.WinNextLine); sb.Append("<ADR_RECORD_DATE>").Append(this.ADR_RECORD_DATE.ToString("yyyy-MM-dd")).Append("</ADR_RECORD_DATE>").Append(HssStr.WinNextLine); sb.Append("<RATIO>").Append(HssStr.WinNextLine); sb.Append("<ADRBase>").Append((int)this.ADRBase).Append("</ADRBase>").Append(HssStr.WinNextLine); sb.Append("<OrdinaryShare>").Append((int)this.OrdinaryShare).Append("</OrdinaryShare>").Append(HssStr.WinNextLine); sb.Append("</RATIO>").Append(HssStr.WinNextLine); sb.Append("</EVENT_INFORMATION>").Append(HssStr.WinNextLine); return(sb.ToString()); }
/// <summary> /// Create sharedStrings.xml /// </summary> private void Create_SharedString_fromDic(Dictionary <string, int> dic, string fileName) { if (string.IsNullOrEmpty(fileName) || dic == null) { return; } string header_str = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" + HssStr.WinNextLine + "<sst xmlns='http://schemas.openxmlformats.org/spreadsheetml/2006/main' " + "count='" + dic.Count + "' uniqueCount='" + dic.Count + "'>" + HssStr.WinNextLine; FileStream fs = new FileStream(fileName, FileMode.Create); byte[] header_bts = Encoding.UTF8.GetBytes(header_str); fs.Write(header_bts, 0, header_bts.Length); StringBuilder sb = new StringBuilder(); int count = 0; foreach (string s in dic.Keys) { sb.Append("<si><t>" + HssStr.ToSafeXML_str(s) + "</t></si>" + HssStr.WinNextLine); if (++count % HssRawExcel.OneTimeAmount == 0) { byte[] arr = Encoding.UTF8.GetBytes(sb.ToString()); fs.Write(arr, 0, arr.Length); sb.Clear(); } ++this.hLog.RecordNum; } if (sb.Length > 0) { byte[] arr = Encoding.UTF8.GetBytes(sb.ToString()); fs.Write(arr, 0, arr.Length); } byte[] tail_bts = Encoding.UTF8.GetBytes("</sst>"); fs.Write(tail_bts, 0, tail_bts.Length); fs.Close(); }