We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export Text with Comment to Clipboard

Thread ID:





100816 Sep 7,2011 02:43 PM UTC Sep 13,2011 12:46 PM UTC WinForms 1
Tags: XlsIO
Zhaojian Li
Asked On September 7, 2011 02:43 PM UTC

Hello, I tried to export a grid to Clipboard with XML Format. The MOST IMPORTENT thing is, some cells of the grid are with ToolTipText, which I want to export as Comment. my Code looks like this:

private void ultraGrid1_KeyDown(object sender, KeyEventArgs e)
if (e.Control && e.KeyCode == Keys.C)
ExcelEngine lExcelEngine = new ExcelEngine();
IApplication lApplication = lExcelEngine.Excel;
lApplication.DefaultVersion = ExcelVersion.Excel2010;

IWorkbook lWorkbook = lApplication.Workbooks.Create(1);

IWorksheet lWorksheet = lWorkbook.Worksheets[0];
Selected lSelected = this.ultraGrid1.Selected;

for (int i = 0; i < lSelected.Cells.Count; i++)
UltraGridCell lUltraGridCell = lSelected.Cells[i];
IRange lRange = lWorksheet.Range[lUltraGridCell.Row.Index + 1, lUltraGridCell.Column.Index + 1];
lRange.Value = lUltraGridCell.Text;
if (!string.IsNullOrEmpty(lUltraGridCell.ToolTipText))
ICommentShape lCommentShape = lRange.AddComment();
lCommentShape.Text = lUltraGridCell.ToolTipText;

//Solution 1: Comments are not included

//Solution 2: Comments are included
MemoryStream lDataObject = new MemoryStream();
//Bug: System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
lWorkbook.SaveAsXml(lDataObject, ExcelXmlSaveType.MSExcel);
Clipboard.SetData("XML Spreadsheet", lDataObject);

But I get an Exception:
bei System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
bei System.Collections.Generic.SortedList`2.GetKey(Int32 index)
bei System.Collections.Generic.SortedList`2.KeyList.get_Item(Int32 index)
bei Syncfusion.XlsIO.Implementation.XmlSerialization.WorkbookXmlSerializator.SerializeRichText(XmlWriter writer, TextWithFormat rtf, String text, FontsCollection fonts, IFont defFont)
bei Syncfusion.XlsIO.Implementation.XmlSerialization.WorkbookXmlSerializator.SerializeComment(XmlWriter writer, IComment comment, FontsCollection fonts, IFont defFont)
bei Syncfusion.XlsIO.Implementation.XmlSerialization.WorkbookXmlSerializator.SerializeCell(XmlWriter writer, WorksheetImpl sheet, Int32 iRowIndex)
bei Syncfusion.XlsIO.Implementation.XmlSerialization.WorkbookXmlSerializator.SerializeRows(XmlWriter writer, WorksheetImpl sheet)
bei Syncfusion.XlsIO.Implementation.XmlSerialization.WorkbookXmlSerializator.SerializeTable(XmlWriter writer, WorksheetImpl sheet)
bei Syncfusion.XlsIO.Implementation.XmlSerialization.WorkbookXmlSerializator.SerializeWorksheet(XmlWriter writer, WorksheetImpl sheet)
bei Syncfusion.XlsIO.Implementation.XmlSerialization.WorkbookXmlSerializator.SerializeWorksheets(XmlWriter writer, IWorksheets worksheets)
bei Syncfusion.XlsIO.Implementation.XmlSerialization.WorkbookXmlSerializator.SerializeWorkbook(XmlWriter writer, IWorkbook book)
bei Syncfusion.XlsIO.Implementation.XmlSerialization.WorkbookXmlSerializator.Serialize(XmlWriter writer, IWorkbook book)
bei Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAsXml(XmlWriter writer, ExcelXmlSaveType saveType)
bei Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAsXml(Stream stream, ExcelXmlSaveType saveType)
bei ClipboardTester.Form1.ultraGrid1_KeyDown(Object sender, KeyEventArgs e) in D:\Development\Travis\miscellaneous\ClipboardTester\ClipboardTester\Form1.cs:Zeile 76.
bei System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)
bei Infragistics.Win.UltraControlBase.OnKeyDown(KeyEventArgs e)
bei System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
bei System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
bei System.Windows.Forms.Control.WmKeyChar(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I have no idea and don't know how can i resolve this problem. The most important thing of this program is, the comments must be exported into Clipboard, so that when I paste the data in the clipboard to Excel, the comments will also be pasted.

Manikandan M [Syncfusion]
Replied On September 13, 2011 12:46 PM UTC

Hi Zhaojian Li,

Thanks for your interest in Syncfusion product.

In default, Xml does not allow to save the comments in cell.So it is not possible to save the comments in xml using XlsIO. And you can use Excel2007 instead of xml to save comments in cell.

Please let us know if need any clarifications.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon