Hello,
I’m using Aspose.Cells version 7.7.2.2
Hi Purnima,
Thanks for your posting and using Aspose.Cells.
Aspose.Cells renders PDF same as MS-Excel shows it in the Print Preview. Please use the following code to print the Excel comments in the PDF.
I have attached the source xlsx file which contains a comment in cell B2 and it is in Open state. Please check it in MS-Excel Print Preview. You will see no comments are shown. You can make them shown using Page Layout > Sheet > Comments (set it as As displayed on sheet).
Or you can do this by code using
worksheet.PageSetup.PrintComments = PrintCommentsType.PrintInPlace;
C#
Workbook workbook = new Workbook(“source.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];
worksheet.PageSetup.PrintComments = PrintCommentsType.PrintInPlace;
workbook.Save(“output.pdf”, SaveFormat.Pdf);
Yes it worked.
No it did not work with my CLI project though it worked with VB project.
Also tried with Aspose.Cells version 7.7.2.3 but it did not work in CLI project.
Hi Purnima,
Thanks for your posting and using Aspose.Cells.
Kindly replace this line inside your temp.cpp file
lXlsWorksheet->PageSetup->PrintComments = PrintCommentsType::PrintNoComments;
with the following line
lXlsWorksheet->PageSetup->PrintComments = PrintCommentsType::PrintInPlace;
It should work fine now.
Let us know if you still face any issue. We will look into it and help you asap.
Hi, CodeSnapshot.JPG (41.3 KB)
PrintCommentInPlace.pdf (19.7 KB)
It is not working for me as well using Aspose.Cells 19.9 version.
Attaching the code file and Output PDF file.
Please look into it.
Thanks for the screenshot and PDF file.
Well, we supported the threaded comments feature some months ago. For your information, this is Office 365 feature so standard MS Excel might not support this. We recommend you to kindly try using simple/standard comments (as per MS Excel 2007/2010/2013/2017) instead of threaded comments, it will work fine. But if you still persist and want to render threaded comments to be placed in the PDF file format, kindly do provide your input file and paste your sample code here, we will check it and may log a ticket for it.
Hi @Amjad_Sahi
I tried with single comment as well which works absolutely fine in Excel but when using PrintCommentsType.PrintInPlace option and saving it to PDF, the comments are not reserved. Instead if I use, print PrintCommentsType.PrintSheetEnd, the comments are displayed at the end of the sheet.
Same is the case with Threaded Comments as well. I am attaching code snippet and the output PDF for both the cases. Please take a look and respond according.
Attaching the code snippet and PDF for single comment below.
SingleComment.JPG (41.6 KB)
SingleComment.pdf (19.7 KB)
Attaching the code snippet and PDF for threaded comment below.
ThreadedComments.JPG (53.2 KB)
ThreadedComments.pdf (19.7 KB)
I am using Aspose.Cells Version 19.9.0.
Thanks.
Thanks for the screenshots and PDF files.
Please add a line to the code segment, it will work fine:
e.g
Sample code:
…
workbook.Worksheets[0].Comments.Add(0,0);
var comment = workbook.Worksheets[0].Comments[0];
comment.Note = “Hi there”;
comment.IsVisible = true;
…
Hi @Amjad_Sahi
Sure, that helps.
I’m attaching the PDF for you.
SingleComment.pdf (24.7 KB)
Also wanted to know if there is any way I could view a comment only on hover on a particular cell in PDF just like how it works in Excel. The way this works as of now is, it overlaps with the data value. So wanted to know if we can avoid that anyhow.
Also, attaching a PDF below for threaded comments. Let me know if there is any solution for threaded comments to be visible in place.
ThreadedComments.pdf (32.7 KB)
Aspose.Cells works the same way as MS Excel does when generating the PDF file. If you could create/open a file into MS Excel with the comments in tact, now save it as PDF file format manually. After this open the file into Adobe acrobat, you will see the same results as per Aspose.Cells. In short, either you can display the comments at the end of the sheet or at its original location in the sheet. Otherwise, comments won’t be shown inserted as hover button/shape.
I am afraid, this is not possible, see the details above. By the way, we have another API named Aspose.PDF which you can use to add comments/notes, etc. to your output PDF document (by Aspose.Cells).
Alright. Got it.
Thanks.
I tried the same thing for threaded comments as well. You can find attachments in previous posts on the same thread. The in-place thing for comments did not work for threaded comments. Please confirm and raise a ticket for the same.
Please try using our latest version/fix v19.10 and provide the following artifacts (resource files and samples, etc.) for threaded comments issue:
- Paste sample code (runnable) here or in text file
- Output Excel file
- Output PDF file
We will evaluate it and then log appropriate ticket to sort it out soon.
Hi, Please find the following things mentioned in the above reply by you.
1. Code Snippet
Workbook workbook = new Workbook();
// Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Add Values
workbook.Worksheets[0].Cells[0, 0].Value = 1;
workbook.Worksheets[0].Cells[0, 1].Value = 1;
workbook.Worksheets[0].Cells[1, 0].Value = 1;
workbook.Worksheets[0].Cells[1, 1].Value = 1;
// Add Threaded Comment
workbook.Worksheets.ThreadedCommentAuthors.Add("Aspose Text", "", "");
var author = workbook.Worksheets.ThreadedCommentAuthors[0];
var index = workbook.Worksheets[0].Comments.AddThreadedComment(0, 0, "Hi there", author);
workbook.Worksheets[0].Comments.AddThreadedComment(0, 0, "Hi bye", author);
var comment1 = workbook.Worksheets[0].Comments[index];
comment1.IsVisible = true;
Aspose.Cells.PdfSaveOptions saveOpt = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
saveOpt.AllColumnsInOnePagePerSheet = true;
worksheet.PageSetup.PrintComments = PrintCommentsType.PrintInPlace;
workbook.Save("D:\\ThreadedComments.pdf", saveOpt);
workbook.Save("D:\\ThreadedComments.xlsx");
2 Output PDF file
ThreadedComments.pdf (32.7 KB)
I am not sure how to attach an Excel file since the system doesn’t support upload of Excel File.
Please check this at your end and let me know.
Please note that this piece of code is tried using Aspose.Cells v19.10.
Thanks
Thanks for the sample code segment and output PDF.
After an initial test, I am able to reproduce the issue as you mentioned by using your sample code with your template file. I found that in place threaded comments are not rendered fine in the output file. I have logged a ticket with an id “CELLSNET-46959” for your issue. We will look into it soon.
Once we have an update on it, we will let you know.
You may zip the file prior to attaching.
@vanshita,
Please share the expected PDF output generated by Microsoft Excel. Also share with us the version details of your Microsoft Excel.