GroupDocsGists
10/24/2017 - 1:02 PM

AddAttachmentExcel.cs

using (CellsDocument doc = Document.Load<CellsDocument>(Utilities.MapSourceFilePath(FilePath)))
{
    CellsWorksheet worksheet = doc.Worksheets[0];

    // Add the attachment
    worksheet.Attachments.AddAttachment(
        File.ReadAllBytes(Utilities.MapSourceFilePath(AttachmentPath)), // File content
        "sample document", // Source file full name (the extension is used to determine appropriate application to open the file) 
        File.ReadAllBytes(Utilities.MapSourceFilePath(AttachmentPath)), // Preview image content
        50, // X-coordinate of the attachment frame
        100, // Y-coordinate of the attachment frame
        200, // Attachment frame width
        400); // Attachment frame height

    // Save changes
    doc.Save();
}