Spreadsheet document area size determination

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 am trying to get row height for some area of template. Using

Code
AreaTemplate.Areas.Totals.RowHeight

i get 0 no matter that AutoRowHeight is false.

How could I find out the size of some template area in mm, and the size of filled template area before putting it to the result document? I need to calculate the quantity of products which could enter one page (or some predefined area).

--- addition

It seems like if you set Height directly for area it stays set, and you can get this from code, but if you set 3 lines of one area in a template (all the lines) then RowHeight for the area will not be set.

I am also wondering how to get RowHeight for the line which have AutoRowHeight, but already was filled with data and putted to resulting Spreadsheet.

Edited: Alexey Gerasimov - Nov 07, 2012 08:08 AM (addition)
 
#2
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

>  I need to calculate the quantity of products which could enter one page
Usually for this problem the method "CheckPut" of SpreadsheetDocument is using.
Maybe it help to you

Edited: ivan avdonin - Nov 07, 2012 09:58 AM
 
#3
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

No this wont help. I need to calculate how many lines would enter some area and then put them into this area and make the next line exactly how it was designed in template.

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

Joined:
Company:

You need to check if your row with footer will fit the page or not. If not you will have to put it on the next page.
See M15 or TORG12 print form generation in PrintForm() procedure of manager module of Sales Invoice document of the Subsystems Library application as an example.

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

Timofey Bugaevsky,
and could I align footer to the bottom of the page?

I have found this code for M15 generation.

Code
TemplateAreaFooter.Parameters.HeadNameAndSurname = Heads.HeadNameAndSurname;
TemplateAreaFooter.Parameters.NameAndSurnameOfChiefAccountant = Heads.ChiefAccountantNameAndSurname;
TemplateAreaFooter.Parameters.HeadPost = Heads.HeadPosition;
TemplateAreaFooter.Parameters.WarehouseManNameAndSurname = Heads.WarehouseManNameAndSurname;
TemplateAreaFooter.Parameters.WarehousemanPosition = Heads.WarehouseMan_Position;
         
TemplateAreaFooter.Parameters.NumberOfRecordOrdinalNumbersInWords = NumberInWords(RowsCount, ,
                                                                                  ",,,,,,,,0");
TemplateAreaFooter.Parameters.AmountInWords = SmallBusinessServer.GenerateAmountInWords(
                                          TotalTotalWithVAT, CurrentDocument.DocumentCurrency);
TemplateAreaFooter.Parameters.Total_VAT = TotalTotalWithVAT - TotalSumWithoutVAT;
         
SpreadsheetDocument.Put(TemplateAreaFooter);


The same for TORG12
Code
TemplateAreaFooter.Parameters.DocumentDateDay = """" + Left(FullDocumentDate, FirstSeparator - 1) 
                                                     + """";
TemplateAreaFooter.Parameters.DocumentDateMonth = Mid(FullDocumentDate, FirstSeparator + 1, 
                                                      SecondSeparator - FirstSeparator - 1);
TemplateAreaFooter.Parameters.DocumentDateYear = Right(FullDocumentDate, 
                                                       StringLength - SecondSeparator);   
      
SpreadsheetDocument.Put(TemplateAreaFooter);


There is nothing that could help me to put footer exactly where I want.

I also looked up for some functions which may help. Document have header and footer which could contain this information:

Quote
This may be used to access the spreadsheet's header and footer. header and footer is special text that is placed at the top or bottom of each page when a document is printed. The following control structures can be used in the header and footer text:
[&PageNumber]- a page number will be printed on this part of the page;
[&PagesTotal] - total number of pages will be printed on this part of the page;
[&Date]- the current date will be printed on this part of the page;
[&Time]- the current time will be printed on this part of the page,
Correct me if I wrong but I can not define custom template for Document footer.

I really need that some fields are exactly in the defined space. Here, there are a lot of document templates which should be filled by printing. So I have some area in the middle of document which is a space for goods. No matter how much goods I have the footer should always be at the same position, at the bottom of the page.

I tried this technique, but it seems not work in 8.3

Code
   TempSD = New SpreadsheetDocument;
   Area.Parameters.BaseImponible = "100";
   Region = TempSD.Put(Area);
   Nota = TempSD.Drawings.Add(SpreadsheetDocumentDrawingType.Text);
   Nota.Place(Region);
   Message(Nota.Height);
   Return Nota.Height;

Edited: Alexey Gerasimov - Nov 09, 2012 05:11 AM
 
#6
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

Sorry, its not for custom template
For writing some text "at the bottom of the page" you can use property Footer of SpreadsheetDocument like so:

Code
TempSD = New SpreadsheetDocument;
TempSD.Footer.Enabled = True;
TempSD.Footer.CenterText = "Test text";


You see this text only at form "Print preview" or after printing.

Edited: ivan avdonin - Nov 09, 2012 10:36 AM
 
#7
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Alexey, I've got your problem.

My suggestion is that you use the described technique but divided into 2 steps.
First, output table rows with data. Stop when the current table row together with the footer does not fit the page.
Second, output empty rows with 1mm height. Stop when the current empty row together with the footer does not fit the page, then output the footer.

You will have precision of 1mm. Guess this will help.

Here is the example:

Code
&AtClient
Procedure Print(Command)
   SpreadsheetDocument = PrintServer();
   SpreadsheetDocument.Show();
EndProcedure

&AtServer
Function PrintServer()
   Result = New SpreadsheetDocument();
   
   DataProcessor = FormAttributeToValue("Object");
   
   Template = DataProcessor.GetTemplate("Template");
   
   Header = Template.GetArea("Header");
   Row = Template.GetArea("Row");
   Compensator = Template.GetArea("Compensator");
   Footer = Template.GetArea("Footer");
   
   Result.Put(Header);
   
   RowsToCheck = New Array();
   RowsToCheck.Add(Row);
   RowsToCheck.Add(Footer);
   
   While Result.CheckPut(RowsToCheck) Do
      Result.Put(Row);
      
      RowsToCheck.Clear();
      RowsToCheck.Add(Row);
      RowsToCheck.Add(Footer);
   EndDo;
      
   RowsToCheck.Clear();
   RowsToCheck.Add(Compensator);
   RowsToCheck.Add(Footer);
   While Result.CheckPut(RowsToCheck) Do
      Result.Put(Compensator);
      
      RowsToCheck.Clear();
      RowsToCheck.Add(Compensator);
      RowsToCheck.Add(Footer);
   EndDo;
   
   Result.Put(Footer);
   
   Return Result;
EndFunction

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

Timofey Bugaevsky,
Thank you for your idea. I used slightly different technique, but I used the idea of PutCheck with spacer.

Surprisingly, one guy of our team advised the same method.

 
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.