Scott,
I figured out how to do it, thanks to another thread on the forums here that covered some of the same territory, and gave me the solution ... which I have slightly updated (and written in VB) here. Here's how you save to a memory stream, and thence to a string, without writing to disk at all:
'--
'-- fpSpread1.Save(FilePath, False) saves the spread state to an XML file.
'-- Save it to an in-memory string instead.
'--
' First, save state to a memory stream instead of a file stream.
Dim ms As New MemoryStream
fpSpread1.Save(ms, False)
' Next, convert that memory stream to a string.
ms.Position = 0
Dim tr As TextReader = New StreamReader(ms, System.Text.Encoding.UTF8, False, 1024)
Dim fpState As New System.Text.StringBuilder
Dim ln As String = tr.ReadLine
While ln IsNot Nothing
fpState.Append(ln)
ln = tr.ReadLine
End While
' fpState now contains the same contents as the XML file that would be produced by fpSpread1.Save.
' If you write it out to a database field, make sure that the field is defined as nvarchar(max).
Then, after reading from the database field to a string fpState, you can restore the spread from it as follows:
'--
'-- fpSpread1.Open(FilePath) loads the spread state from an XML file.
'-- Load it from a string fpState instead.
'--
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.LoadXml(fpState)
Dim ms As New MemoryStream
xmlDoc.Save(ms)
ms.Position = 0
fpSpread1.Open(ms)
You might want to have this posted on the "How to" section of the web site.
Regards,
C17