Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3952066
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:48:21+00:00 2026-05-20T01:48:21+00:00

I have WPF DataGrid (VS2010 C#). I copied the data from DataGrid to Clipboard

  • 0

I have WPF DataGrid (VS2010 C#). I copied the data from DataGrid to Clipboard and write it to an Excel file. Below is my code.

dataGrid1.SelectAllCells();
dataGrid1.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
ApplicationCommands.Copy.Execute(null, dataGrid1);
dataGrid1.UnselectAllCells();
string path1 = "C:\\test.xls";
string result1 = (string)Clipboard.GetData(DataFormats.CommaSeparatedValue);
Clipboard.Clear();
System.IO.StreamWriter file1 = new System.IO.StreamWriter(path1);
file1.WriteLine(result1);
file1.Close();

Everything works out OK except when I open the excel file it gives me two warning:

“The file you are trying to open
‘test.xls’ is in a different format
than specified by the file extension.
Verify that the file is not corrupted
and is from a trusted source before
opening the file. Do you want to open
the file now?”

“Excel has detected that ‘test.xls’ is
a SYLK file, but cannot load it.”

But after I click through it, it still open the excel file OK and data are formated as it supposed to be. But I can’t find how to get rid of the two warnings before the excel file is open.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:48:22+00:00Added an answer on May 20, 2026 at 1:48 am

    A problem like yours has already been described here : generating/opening CSV from console – file is in wrong format error.
    Does it helps to solve yours ?

    Edit : Here is the Microsoft KB related => http://support.microsoft.com/kb/323626

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wpf datagrid that has it's columns generated dynamically in code and
I have a WPF Datagrid binded with list of interface objects. Consider, ClsEmployee class
I have a wpf datagrid, Here's my datagrid <dg:DataGrid x:Name=dataGrid AutoGenerateColumns=false ColumnHeaderStyle={StaticResource columnHeaderStyle} AlternationCount=2
I have a WPF DataGrid which has an AlternatingRowBackground brush. It's configured to color
I currently have a WPF DataGrid binded to a DataSet via the DataGrid's ItemsSource
Using the WPF DataGrid I have the need to change various display and related
I have binded a list with Editable WPF DataGrid I want to get only
I have created a custom style for my WPF datagrid by overriding its control
I have a very large comma-seperated text-file. I need to display this in a
I have a WPF application, i created a new class named Agent . On

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.