I want to create a data structure that I can copy to the clipboard in such a way that the user can paste it into an Excel worksheet and it inserts correctly into the columns and rows of the sheet.
Is there any way to create such a data structure? Or does it already exist?
I would like to avoid having to open up Excel and pasting the values myself because I can’t determine if the worksheet will look the same in the future, so I’d rather have the user himself copy the rows and columns where he wants them.
When copying the data to clipboard, format it as Tab separated for columns, and Enter separated for rows. When pasting in Excel it will automatically put the values in rows and columns.
You can copy your data to clipboard in a tab-delimited textual format.
A tab or comma delimited string is the easiest and least technical solution.
Assuming you want something a little more complicated there are some superb libraries around (search CodePlex) which can offer creating Excel documents in managed code.
Or you could use the interop libraries that come ad part of the Visual Studio office integration.
Or you could use the XLSX format based on XML.