为什么保存为xml格式时,有包含ActiveSheet.Tag的属性,保存为xlsx格式后,ActiveSheet.Tag的属性值丢失
代码如下:
public MainWindow()
{
InitializeComponent();
this.Loaded += MainWindow_Loaded;
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
GcSpreadSheet spread2 = new GcSpreadSheet();
using (MemoryStream stream = new MemoryStream(GetXlsxFormatFileContent()))
{
spread2.OpenExcel(stream);
//spread2.OpenXml(stream);
}
object tag = spread2.ActiveSheet.Tag;
MessageBox.Show(tag == null ? "不存在Tag值" : tag.ToString());
}
private byte[] GetXlsxFormatFileContent()
{
GcSpreadSheet spread1 = new GcSpreadSheet();
spread1.ActiveSheet.Tag = "这是Tag属性";
spread1.ActiveSheet.Cells[0, 0].Text = "这是A1";
using (MemoryStream stream = new MemoryStream())
{
spread1.SaveExcel(stream, ExcelFileFormat.XLSX, ExcelSaveFlags.SaveAsViewed);
//spread1.SaveXml(stream);
return stream.ToArray();
}
}
|
|