xlsgen > overview > Comments

 


Creating comments

Comments are useful to add user-specific information to worksheets without altering the content. The Comment API in xlsgen allows the following :

The comment interface is described here.

It is also possible to enumerate comments, by index or by location. See the IXlsComments interface here.

 

Below is an example of comment creation :

VB code

' this piece of code must be added in a VB module

Declare Function Start Lib "xlsgen.dll" () As CoXlsEngine


Sub generate()

Dim engine As CoXlsEngine
Set engine = Start()

Dim wbk As IXlsWorkbook
Set wbk = o.New("sample.xls")

Dim w As IXlsWorksheet
Set w = wbk.AddWorksheet("name1")

Dim comment1 As IXlsComment 
Set comment1 = w.NewComment(3,2)
comment1.Label = "a comment"
comment1.BackColor = &H00AA4499
comment1.Translucid = True
comment1.Location 6,5,13,8

wksht.Label(7,2) = "a label"

Dim comment2 As IXlsComment 
Set comment2 = w.NewComment(7,2)
comment2.Label = "another comment"
comment2.AlwaysShow = True
comment2.Author = "someone"

wbk.Close

End Sub

C# code

[DllImport("xlsgen.dll")]
static extern IXlsEngine Start();

IXlsEngine engine = Start();
IXlsWorkbook wbk = engine.New( @"sample.xls" );
IXlsWorksheet wksht = wbk.AddWorksheet( "samplesheet" );

IXlsComment comment1 = wksht.NewComment(3,2);
comment1.set_Label("a comment");
comment1.set_BackColor(0x00AA4499);
comment1.set_Translucid(1);
comment1.Location(6,5,13,8);

wksht.set_Label(7,2, "a label");

IXlsComment comment2 = wksht.NewComment(7,2);
comment2.set_Label("another comment");
comment2.set_AlwaysShow(true);
comment2.set_Author("someone");

wbk.Close();

Java code

XlsEngine engine = new XlsEngine("xlsgen.dll");

XlsWorkbook workbook = engine.New("sample.xls");
XlsWorksheet wksht = workbook.AddWorksheet("samplesheet");

XlsComment comment1 = wksht.NewComment(3,2);
comment1.putLabel("a comment");
comment1.putBackColor(0x00AA4499);
comment1.putTranslucid(true);
comment1.Location(6,5,13,8);

wksht.putLabel(7,2, "a label");

XlsComment comment2 = wksht.NewComment(7,2);
comment2.putLabel("another comment");
comment2.putAlwaysShow(true);
comment2.putAuthor("someone");

workbook.Close();

C++ code

// note : the xlsgenLoader class loads xlsgen as a regular dll, and calls 
//  the Start() entry point
xlsgenLoader xlsgen("xlsgen.dll");

if (!xlsgen.IsInitialized())
  return;
  
xlsgen::IXlsEnginePtr engine = xlsgen.Start();
xlsgen::IXlsWorkbookPtr wbk = engine->New( L"sample.xls" );
xlsgen::IXlsWorksheetPtr wksht = wbk->AddWorksheet( L"samplesheet" );

xlsgen::IXlsCommentPtr comment1 = wksht->NewComment(3,2);
comment1->Label = L"a comment";
comment1->BackColor = 0x00AA4499;
comment1->Translucid = TRUE;
comment1->Location(6,5,13,8);

wksht->Label[7][2] = L"a label";

xlsgen::IXlsCommentPtr comment2 = wksht->NewComment(7,2);
comment2->Label = L"another comment";
comment2->AlwaysShow = TRUE;
comment2->Author = L"someone";

wbk->Close();

 

xlsgen documentation. © ARsT Design all rights reserved.