C# Add excel text-formatted data to clipboard

前端 未结 3 1121
逝去的感伤
逝去的感伤 2021-01-19 10:15

In C# I need to copy data-grid rows to excel. Because some values in a row are doubles, \"-Infinity\" values are possible.

I\'ve tried to copy the rows

3条回答
  •  时光说笑
    2021-01-19 10:53

    Thanks for the info. After some more searching, I found that you can use the .Net clipboard class, but you can't pass a String to SetData(). This works for me:

    System::Text::UTF8Encoding^ enc = gcnew System::Text::UTF8Encoding();
    System::Windows::Forms::Clipboard::SetData("XML Spreadsheet", gcnew MemoryStream(enc->GetBytes(data)));
    

提交回复
热议问题