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:

Created:

Updated:

Platform:

Replies:

100814 Sep 7,2011 12:57 PM UTC Feb 28,2018 04:40 AM UTC ASP.NET Web Forms (Classic) 5
loading
Tags: XlsIO
Zhaojian Li
Asked On September 7, 2011 12:57 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
//lWorksheet.CopyToClipboard();

//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.



Sridhar [Syncfusion]
Replied On September 8, 2011 01:32 PM UTC

Hi Zhaojian,

Thank you very much for using Syncfusion products.

In your previous post we could see you are using the UltraGrid Control to export in in to the excel document. We have tried to download the prodcut at our side and we are unable use it at our side. We could not find the download link for the same.
So we have created the XlsIO sample at our side for the above requirement and updated here for your reference. We are using 9.3.0.61 version and let us know the essential studio version you are using at your side.

Please try the sample at your side and let us know if these helps you. If you still face the issue, Please get back to us with the sample to proceed further.

Please let us know if you require any further clarifications.

Thanks,
Sridhar.S



CommentsToClipboard_5e5a27cc.zip

Zhaojian Li
Replied On September 8, 2011 02:43 PM UTC

Hello, Thank you for your answer, I have tried your Example, it work at first. But after that, I add one line to it, it shows the same error:

IRange range = sheet.Range["C6"];
>>> range.Text = "QQ";

ICommentShape cShape = range.AddComment();
cShape.Name = "comment";
cShape.Text = "Sycnfusion-test-Xml comment";

That means Rang.Text must be empty or the cShape.Text must be empty.


Zhaojian Li
Replied On September 8, 2011 02:46 PM UTC

But I should export the cell which is not empty and the comment also with content.


Sridhar [Syncfusion]
Replied On September 9, 2011 02:11 PM UTC

Hi Zhaojian,

Thanks for the update.

We are able to reproduce the reported issue at our side and suspect this could be a defect.

So we request you to open a new direct-trac incident with a simple issue reproducing sample for further follow up on this issue.

Direct-Trac Link:
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please, let us know if you require any further clarifications.

Thanks,
Sridhar.S



Andre
Replied On February 28, 2018 04:40 AM UTC

Hi Zhaojian,

Thanks for the update.

We are able to reproduce the reported issue at our side and suspect this could be a defect.

So we request you to open a new direct-trac incident with a simple issue reproducing sample for further follow up on this issue.

Direct-Trac Link:
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please, let us know if you require any further clarifications.

Thanks,
Sridhar.S



Community License

CONFIRMATION

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.

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

;