Insert, Edit or Delete Notes in Spreadsheet Documents Using SpreadProcessing

Check out this blog post to get an overview of the Notes functionality in SpreadProcessing.


This content originally appeared on Telerik Blogs and was authored by Tanya Dimitrova

Check out this blog post to get an overview of the Notes functionality in SpreadProcessing.

One of the new additions to the SpreadProcessing library is support for Notes. Notes help you annotate the data inside cells or make it clearer by including additional information for the cell content. The SpreadProcessing API enables you to iterate all notes in a document, modify them or create new ones.

No matter whether you need to add, delete or modify a note, all the SpreadsheetNote objects can be accessed through the Notes collection of your Worksheet. The collection exposes simple methods to add or remove a note as well as an indexer, enabling you to iterate all the notes that are currently inside the document.

The code in the next snippet shows how you can open an XLSX document and delete all notes in the first Worksheet:

Workbook workbook;
using (Stream str = File.OpenRead(sampleFilePath))
{
    XlsxFormatProvider provider = new XlsxFormatProvider();
    workbook = provider.Import(str);
}
 
workbook.Worksheets[0].Notes.Clear();

OK. That was pretty easy, but what about creating a note or modifying an existing one? Don’t worry—it is simple as well. 

All that you need to specify when inserting a new note is the cell the note refers to and the position of the note. Let’s create a simple spreadsheet document to demonstrate that.

// Create document
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets.Add();
 
CellIndex a1Index = new CellIndex(0, 0);
worksheet.Cells[a1Index].SetValue("Example here");
worksheet.Cells[a1Index].SetIsWrapped(true);
 
// Create and add a note
// The index of the cell the note is associated to. (A1 in this case)
CellIndex relatedCellIndex = a1Index;
// The index of the cell the note will be visualized on when all notes are shown. (C3 in this case)
CellIndex cellIndex = new CellIndex(2, 2);
string author = "John Doe";
string text = "My First Comment Content";
 
worksheet.Notes.Add(relatedCellIndex, cellIndex, author, text);
 
// Save document
using (Stream stream = File.OpenWrite("InsertNote.xlsx"))
{
    XlsxFormatProvider provider = new XlsxFormatProvider();
    provider.Export(workbook, stream);
}

Once you open the file generated by the above code, you will see the little red triangle in the top right corner of the cell indicating that there is a note on that cell. Hovering the cell will show you the note we have just inserted:

Notes in spreadsheet produced by SpreadProcessing

If you would like, you can also show the comments inside your worksheet—this ensures that they are always visible, and the users don’t need to hover on a cell to see them on their arranged positions.

The next snippet and image show how to set the notes to be visible and how that will look in the document:

worksheet.Notes.ShowAll();

Show all Notes

As you can see from the image, the note is positioned on the index we have initially applied to it.

The SpreadProcessing API exposes different possibilities for manipulating or deleting existing notes as well as adding new ones. You can change the note content, position, size, visibility and more. If you are curious to explore all of them, head out to the documentation page for this feature: SpreadProcessing | Notes topic.

Try It and Share Your Feedback 

No matter if you are already familiar with Telerik Document Processing or will meet the libraries for the first time, hurry up and get the latest bits so you can take advantage of the different document management possibilities they provide:

Download a Free Trial

And I am sure I have told you many times that your input is valuable. We do listen. So, do not be shy and drop us a line to share your feedback in the comments section below or directly in our Document Processing Libraries Feedback Portal


This content originally appeared on Telerik Blogs and was authored by Tanya Dimitrova


Print Share Comment Cite Upload Translate Updates
APA

Tanya Dimitrova | Sciencx (2022-04-28T11:45:00+00:00) Insert, Edit or Delete Notes in Spreadsheet Documents Using SpreadProcessing. Retrieved from https://www.scien.cx/2022/04/28/insert-edit-or-delete-notes-in-spreadsheet-documents-using-spreadprocessing/

MLA
" » Insert, Edit or Delete Notes in Spreadsheet Documents Using SpreadProcessing." Tanya Dimitrova | Sciencx - Thursday April 28, 2022, https://www.scien.cx/2022/04/28/insert-edit-or-delete-notes-in-spreadsheet-documents-using-spreadprocessing/
HARVARD
Tanya Dimitrova | Sciencx Thursday April 28, 2022 » Insert, Edit or Delete Notes in Spreadsheet Documents Using SpreadProcessing., viewed ,<https://www.scien.cx/2022/04/28/insert-edit-or-delete-notes-in-spreadsheet-documents-using-spreadprocessing/>
VANCOUVER
Tanya Dimitrova | Sciencx - » Insert, Edit or Delete Notes in Spreadsheet Documents Using SpreadProcessing. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/28/insert-edit-or-delete-notes-in-spreadsheet-documents-using-spreadprocessing/
CHICAGO
" » Insert, Edit or Delete Notes in Spreadsheet Documents Using SpreadProcessing." Tanya Dimitrova | Sciencx - Accessed . https://www.scien.cx/2022/04/28/insert-edit-or-delete-notes-in-spreadsheet-documents-using-spreadprocessing/
IEEE
" » Insert, Edit or Delete Notes in Spreadsheet Documents Using SpreadProcessing." Tanya Dimitrova | Sciencx [Online]. Available: https://www.scien.cx/2022/04/28/insert-edit-or-delete-notes-in-spreadsheet-documents-using-spreadprocessing/. [Accessed: ]
rf:citation
» Insert, Edit or Delete Notes in Spreadsheet Documents Using SpreadProcessing | Tanya Dimitrova | Sciencx | https://www.scien.cx/2022/04/28/insert-edit-or-delete-notes-in-spreadsheet-documents-using-spreadprocessing/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.