Show SpreadSheet from custom line

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

I have some form which includes Spreadsheet document as one of the elements. This document is A4 size and often you can not visualize all the document due to screen resolution. This document have header and footer which are not very important to review, but should present in the document. Is there any way to show by default the body part of the document with scrolling bar so the user is still able to review complete document, but on opening it focus on the most important part of the document?

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Alexey.

Try using groups of SpreadsheetDocument.

Code
Spreadsheet = New SpreadsheetDocument;
Section = Spreadsheet.GetArea("R1");
Section.Area("R1C1").Text = NStr("en = 'Number of employees'");
Spreadsheet.Put(Section);
Spreadsheet.StartRowGroup(NStr("en = 'By all departments'"), True);
All = 0;
For H=1 To 3 Do   
    Value = H; Total = 0;  
    Section.Area("R1C1").Text = StrTemplate(NStr("en = 'Department %1'"), H);
    Section.Area("R1C2").Text = "";
    Spreadsheet.Put(Section);
    Spreadsheet.StartRowGroup(StrTemplate(NStr("en = 'Department %1'"), H), True);
    Section.Area("R1C1").Text = NStr("en = 'Group'");
    Section.Area("R1C2").Text = NStr("en = 'Number'");
    Section.Area("R1C2").HorizontalAlign = 
        HorizontalAlign.Auto;
    Spreadsheet.Put(Section);
    Spreadsheet.StartRowGroup(StrTemplate(NStr("en = 'Group %1'"), H), True);
    For K=1 To 4 Do
        Section.Area("R1C1").Text = StrTemplate(NStr("en = 'A%1%2'"), H, K);
        Section.Area("R1C2").Text = Value;
        Spreadsheet.Put(Section);
        Total = Total + Value;
        Value = Value + 10;
    EndDo;
    Spreadsheet.EndRowGroup(); // end the "Group" group
    Spreadsheet.EndRowGroup(); // end the "Department" group
    Section.Area("R1C1").Text = NStr("en = 'Total %1'"), H);
    Section.Area("R1C2").Text = Total;
    Spreadsheet.Put(Section);
    Section.Area("R1C1:R1C2").Text = "";
    Spreadsheet.Put(Section);
    All = All + Total;
EndDo;
Spreadsheet.EndRowGroup(); // end the "By all departments" group
Section.Area("R1C1").Text = NStr("en = 'Total:'");
Section.Area("R1C2").Text = All;
Spreadsheet.Put(Section);
Spreadsheet.TotalsBelow = False;
Spreadsheet.ShowGrid = False;
Spreadsheet.Protection = False;
Spreadsheet.ReadOnly = True;
Spreadsheet.Show(NStr("en = 'Example of using the StartRowGroup() method'"));

 
#3
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

This will make "plus" controls to collapse data, right? But could I scroll document from code?

 
#4
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Alexey, you can create already collapsed groups by specifying False as the second parameter of StartRowGroup() method.

Maybe you could also find useful setting the current area of the spreadsheet document form item:

Code
Items.SpreadsheetDocument.CurrentArea = Items.SpreadsheetDocument.Area("R10C1:R30C10");

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.