MESCIUS SPREAD for Windows Forms 17.0J
Serialize(XmlTextWriter,Boolean) メソッド

オブジェクトの保存先のXmlTextWriterオブジェクト
データソースと連結データを保存するかどうかを表すブール値
オブジェクトをXMLに保存します。データソースと連結データを 保存するかどうかを指定できます。
構文
'Declaration
 
Public Overloads Function Serialize( _
   ByVal w As XmlTextWriter, _
   ByVal saveDataSource As Boolean _
) As Boolean
public bool Serialize( 
   XmlTextWriter w,
   bool saveDataSource
)

パラメータ

w
オブジェクトの保存先のXmlTextWriterオブジェクト
saveDataSource
データソースと連結データを保存するかどうかを表すブール値
次のサンプルコードは、モデルとそのデータソースをシリアル化します。
Dim ds As New DataSet()
Dim emp As New DataTable("Employees")
Dim div As New DataTable("Division")
emp.Columns.Add("LastName")
emp.Columns.Add("FirstName")
emp.Rows.Add(New Object() {"Jones", "Marianne"})
emp.Rows.Add(New Object() {"Fieldes", "Anna"})
div.Columns.Add("Section")
div.Columns.Add("Specialty")
div.Rows.Add(New Object() {"Finance", "Taxes"})
div.Rows.Add(New Object() {"Mergers", "Legal"})
ds.Tables.AddRange(New DataTable() {emp, div})
Dim dataModel As New FarPoint.Win.Spread.Model.DefaultSheetDataModel()
dataModel.DataSource = ds
dataModel.DataMember = "Division"
FpSpread1.ActiveSheet.Models.Data = dataModel
Dim fileName As String
Dim stream As System.IO.Stream
Dim writer As System.Xml.XmlTextWriter
fileName = "D:\Temp\myser.xml"
stream = System.IO.File.Open(fileName, System.IO.FileMode.Create)
writer = New System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8)
writer.Formatting = System.Xml.Formatting.Indented
writer.Indentation = 2
writer.WriteStartDocument()
writer.WriteStartElement("DataModel")
dataModel.Serialize(writer, True)
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()
DataSet ds = new DataSet();
DataTable emp = new DataTable("Employees");
DataTable div = new DataTable("Division");
emp.Columns.Add("LastName");
emp.Columns.Add("FirstName");
emp.Rows.Add(new Object[] {"Jones", "Marianne"});
emp.Rows.Add(new Object[] {"Fieldes", "Anna"});
div.Columns.Add("Section");
div.Columns.Add("Specialty");
div.Rows.Add(new Object[] {"Finance", "Taxes"});
div.Rows.Add(new Object[] {"Mergers", "Legal"});
ds.Tables.AddRange(new DataTable[] {emp, div});
FarPoint.Win.Spread.Model.DefaultSheetDataModel dataModel = new FarPoint.Win.Spread.Model.DefaultSheetDataModel(5, 5);
dataModel.DataSource = ds;
dataModel.DataMember = "Division";
fpSpread1.ActiveSheet.Models.Data = dataModel;
string fileName = "D:\\Temp\\myser.xml";
System.IO.Stream stream = System.IO.File.Open(fileName, System.IO.FileMode.Create);
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream,     System.Text.Encoding.UTF8);
writer.Formatting = System.Xml.Formatting.Indented;
writer.Indentation = 2;
writer.WriteStartDocument();
writer.WriteStartElement("DataModel");
dataModel.Serialize(writer, true);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
参照

DefaultSheetDataModel クラス
DefaultSheetDataModel メンバ
オーバーロード一覧
CanSerializeXml プロパティ

 

 


© MESCIUS inc. All rights reserved.