0

I have an in memory DataTable in C#. I want to save a local copy of that on to my file system and retrive it . This C# datatable captures results from an excel formula and saves it. When the same excel file is opened again, I want to have the datatable loaded. This table is like a local cache that I want to reuse.

Is there any other structure that I can use apart from a data table for such a caching behavior?

How do I do that?

3 Answers 3

2

If you aren't really worried about the format of the output, the easiest solution are the WriteXml and ReadXml methods on the DataSet.

DataSet data = new DataSet();

// Populate from excel

data.WriteXml(fileName, XmlWriteMode.WriteSchema); // Save to file
data.ReadXml(fileName); // Restore from file
Sign up to request clarification or add additional context in comments.

Comments

0

Sounds like you want XML Serialization.

http://devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=236

Comments

0

I would imagine a relational database like SQL Server would work quite well (especially since you are already storing the data in a tabular structure).

1 Comment

0 vote down check I do not want a database like SQL. To explain my case clearly , I have a user defined function that an excel user uses. The formula does its calculations that writes to a data table or any other object on C# . I want this data table or object to be made available when an user opens the excel file again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.