I tried the below using XamSpreadsheet (version 19.2) but am getting a MissingMethodException (seems it is looking for LoadXLSXFunc). Thought this would be pretty straightforward. Any ideas what I am missing or improvements?
var ss = new XamSpreadsheet();ss.Workbook.Worksheets[0].Rows[0].Cells[0].Value = "Test0";ss.Workbook.Worksheets[0].Rows[0].Cells[1].Value = "Test1";ss.Workbook.Worksheets[0].Rows[0].Cells[2].Value = "Test2";ss.Workbook.Worksheets[0].Rows[1].Cells[0].Value = "TestA";ss.Workbook.Worksheets[0].Rows[1].Cells[1].Value = "TestB";ss.Workbook.Worksheets[0].Rows[1].Cells[2].Value = "TestC";ss.ExecuteCommand(SpreadsheetCommandType.Copy, null);
Exception:
+ base {System.MissingMethodException: Method not found: 'System.Func`4<Infragistics.Documents.Excel.Workbook,System.IO.Stream,Infragistics.Documents.Excel.WorkbookLoadOptions,Infragistics.Documents.Core.WorkItem> Infragistics.Documents.Excel.Workbook.get_LoadXLSXFunc()'. at Infragistics.Controls.Grids.Core.WorkbookDataOnjectManager..ctor(Workbook workbook) at Infragistics.Controls.Grids.Core.Spreadsheet.CopyToClipboard(Boolean cut) at Infragistics.Controls.Grids.Core.Spreadsheet.ExecuteCommand(SpreadsheetCommandType command, Object commandParameter, Object sourceElement,LongValue currentState) at Infragistics.Controls.Grids.XamSpreadsheet.ExecuteCommand(SpreadsheetCommandType command, Object parameter)
To answer your first question all the formats we cover are listed here: https://ko.infragistics.com/help/wpf/spreadsheet-work-clipboard
They include BIFF8 CSV and TSV
There is nothing in the XamSpreadSheet that will automatically format the clipboard copied content, but you can overwrite it by setting up a CommandExecuted event and then formating the data in the clipboard like so
Xaml
<ig:XamSpreadsheet x:Name="xamSpreadsheet1" CommandExecuted="xamSpreadsheet1_CommandExecuted"> </ig:XamSpreadsheet>
Codebehind
private void xamSpreadsheet1_CommandExecuted(object sender, Infragistics.Controls.Grids.SpreadsheetCommandExecutedEventArgs e) { if (e.Command.ToString() == "Copy") { var data = Clipboard.GetText();//get the data string textData = "I want to put this string on the clipboard.";//reformat data Clipboard.SetData(DataFormats.Text, (Object)textData); } }
If you are looking for more functionality in changing the copy format on the fly you can submit a new product idea here: https://ko.infragistics.com/community/ideas/i/ultimate-ui-for-wpf
Let me know if this is what you are looking for.
Thanks. It looks like there was a version mismatch in some of the Infragistics dlls the project was referencing.
One followup question. Is there a way to control which data formats are supplied when copying the XamSpreadsheet to the clipboard? For example, when copying from Excel, about two dozen formats are made available in the clipboard (text, html, xml spreadsheet, etc.). Can XamSpreadsheet provide the same formats as Excel does?
Alright, looks like there was some version mismatch between some of the Infragistics assemblies I was referencing. I can copy the cells now.
One followup question. Which data formats are supplied when copying a XamSpreadsheet? When copying from Excel for example, about two dozen formats are available in the clipboard (text, html, xml spreadsheet, etc.). Can I control which formats XamSpreadheet provides when copying? Can it be made to match how Excel works when copying?
Based on what you have provided I have not been able to reproduce the behavior you are experiencing.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using wpf 20.1.93 and 19.2.352
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if I can provide any further assistance.
wpfXamSpreadsheet.zip