Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Show SpreadSheet from custom line

Forum

Search UsersRules
Show SpreadSheet from custom line
#1
Interested
Points:: 15
Joined:: Oct 27, 2011

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?

Profile
#2
Guest
Points::
Joined::

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'"));

Profile
#3
Interested
Points:: 15
Joined:: Oct 27, 2011

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

Profile
#4
Guest
Points::
Joined::

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");

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.