ALV: Extra row to group columns
Hi,
I want to add one more row above column headers (Coltext) to group columns:
1st row: | A | B | C
2nd row: |X | Y | Z | X | Y | Z | X | Y | Z
3rd row: <a long fix text>
following rows are the contents
Three parent columns, 3 child columns under each parent.
How to do it using SALV/ ALV OO?
If the columns are all dynamic ( might be more than 3 columns each parent), how to do?
Thanks in advance!
Thanks!
I did some research and maybe I can use CL_GUI_COLUMN_TREE class to achieve this. Is there a way to edit the fields of the columns?
HD
Similar Messages
-
On ALV report in1 column I want to put Icon on every row of that column.
On ALV report there is 1 column I want to put Icon on every row of that column.That ALV program uses object oriented concept all class and methods.
I want to use that icon on that row. That icon name is ICON_OKAY
In my program when I assign values to internal table at that time I am assigning that ICON_OKAY value to that row as follow.
Itab-
Itab-icon = ICON_OKAY.
Append itab.please follow below procedure to display icon in ALV
1) In corresponding fieldcatelog entry do
fieldcatalog-icon = 'X'
2) While filling the internal table fill the corresponding key value of icon , for example ICON_OKAY value is '@0V@' so statement would be
Itab-icon = '@0V@'
to get list of corresponding key for icon open include <ICON> in se38 -
ALV List in the same Column for the row CELL i need button or value
Hi,
In my ALV list for the same column I need Button or Value for the different rows (CELL) depending upon my condition.
as well as I have to make read only of 3 rd column CELL based on my first column dropdown value CELL for this Row Only.
Depends upon the value in column 1 / row 2 I have to read only the CELL of column 5 / row 2 ie for the same row.
Depends upon the value in Column 1/ row 3 I have to EDITABLE or Button the CELL of column 5 / row 3 ie for the same row
How to do the logic for this.
I tried and got it for the entire column only.
But my requirement is for the sepecific cell in the column.
Kindly help to proceed further.
Thanks in advance.
DavHere is how you can make a particular cell in the row read-only based on certain conditions.
In my example I am displaying the flight details in an ALV. Here I am checking the airline id and if it is "AA' I am making the cell in the column airline id as readonly. In my example I am putting a check and readonly on the same column. However you can do this for different columns as well.
In order to achieve this you need to add a new context attribute 'READONLY' of type abap_bool to the context node which is bound to data node of ALV.
The method where I populate the node has the following code to populate the data.
data: lr_input_node type ref to if_wd_context_node,
lr_flight_node type ref to if_wd_context_node,
lv_cityfrom type s_from_cit,
lv_cityto type s_to_city,
ls_from type bapisfldst,
ls_to type bapisfldst,
lt_flights type table of bapisfldat,
ls_flights type bapisfldat.
data: lt_final type if_mainview=>elements_node_flighttab,
ls_final type if_mainview=>element_node_flighttab.
* Instantiate the variable lr_input_note to the node NODE_FLIGHT
lr_input_node = wd_context->get_child_node( name = 'NODE_FLIGHT' ).
* Instantiate the variable lr_flight_note to the node NODE_FLIGHTTAB
lr_flight_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' )
* Get the attributes CityFrom und CityTo
lr_input_node->get_attribute( exporting name = 'CITYFROM'
importing value = lv_cityfrom ).
lr_input_node->get_attribute( exporting name = 'CITYTO'
importing value = lv_cityto ).
* Fill the stuctures ls_from and ls_to
ls_from-city = lv_cityfrom.
ls_to-city = lv_cityto.
* Call the function BAPI_FLIGHT_GETLIST
call function 'BAPI_FLIGHT_GETLIST'
exporting
destination_from = ls_from
destination_to = ls_to
tables
flight_list = lt_flights.
Now I am going to check if the airline id is 'AA' and based on that I will fill the readonly context attribute.
loop at lt_flights into ls_flights.
MOVE-CORRESPONDING ls_flights to ls_final.
if ls_flights-airlineid = 'AA'.
ls_final-readonly = abap_true.
else.
ls_final-readonly = abap_false.
endif.
append ls_final to lt_final.
endloop.
Finally bind the data to the context node.
* Bind the data to the node NODE_FLIGHTTAB
lr_flight_node->bind_elements( lt_final ).
Now you need to do the ALV configuration settings.
* create an instance of ALV component
DATA:
lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage.
lr_salv_wd_table_usage = wd_this->wd_cpuse_alv( ).
IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
lr_salv_wd_table_usage->create_component( ).
ENDIF.
* get ALV component
DATA:
lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
CALL METHOD wd_this->alv_config_table->if_salv_wd_table_settings~set_read_only
EXPORTING
VALUE = ABAP_FALSE
* set visible row count
DATA:
lr_table_settings TYPE REF TO if_salv_wd_table_settings.
lr_table_settings ?= wd_this->alv_config_table.
lr_table_settings->set_visible_row_count( '10' ).
DATA:
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_column TYPE REF TO cl_salv_wd_column.
lr_column_settings ?= wd_this->alv_config_table.
DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
lr_column = lr_column_settings->get_column( 'AIRLINEID' ).
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'AIRLINEID'.
lr_column->set_cell_editor( lr_input_field ).
lr_input_field->set_read_only_fieldname( value = 'READONLY' ).
CALL METHOD lr_column_settings->delete_column
EXPORTING
id = 'READONLY' -
I am working on a chart in pages with 7 columns.
Problem has occurred with amount of rows. I have completed 999 rows and it won't allow me to continue. As I need to do approx 3000+ rows, can anyone explain to me how to add extra rows. Thanks JaneTry posting in the Pages forum
https://discussions.apple.com/community/iwork/pages -
How can I do a Header Group Using Group columns for WD ALV tables
Hi
I want to group columns into a header group.
Eg:
from Date
Availability
to date
Any ideas if it is possible with WD ALV tables?Hi,
Try to use the if_salv_wd_field_settings for the column grouping of the Model object.
Also check the class CL_SALV_WD_FIELD.
Regards,
Lekha. -
Different number of rows for different columns in JTable
hi
I need to create a JTable with different number of rows for different columns...
Also the rowheight should be different in each column...
say there is a JTable with 2 columns... Col1 having 5 rows and column 2 having 2 rows...
The rowHeight in Col2 should be an integer multiple of Rowheight in Col1
how do I do this ??
can anybody send me some sample code ?????
thanx in advanceHow about nesting JTables with 1 row and many columns in a JTable with 1 column and many rows.
Or you could leave the extra columns null/blank.
You could use a GridBagLayout and put a panel in each group of cells and not use JTable at all.
It would help if you were more specific about how you wanted it to appear and behave. -
Export to Excel - Problem with extra rows
Hi have a report that has 3 groups. I suppress the group headers and am using the group footers for totals.
When I export to excel, I get extra rows in the excel file for the suppressed sections. How can I get rid of these?
Thanks,
LindaI can use this to get out additional rows on my excel export. However, in the columns, I usually put some distance between each column so the columns won't run together. This is giving me extra columns. It would be much easier if I did not have to put that distance. Is there a way to format the field to have a leading or trailing space so all the fields don't run together on the report?
example:
field1
field2
field 3
if all these fields have data the output would look like:
field1datafield2datafield3data
how can I make it look like:
field1data field2data field3data -
ALV totals row ,should not download in EXCEL
Hello ,
I have developed a ALV report with subtotals.
In the output, it will display an extra row with the Grand total, but when we try to downalod into Local PC excel file,
it is downlaoding the totals row also. But the requirement is not to download that.
Any option is there to not to downlad that row ?
Let me know if anything needed.
Thanks,
AVHi,
I will suggest one thing.
<li>Define layout structure
DATA: wa_layout type SLIS_LAYOUT_ALV.
<li>One checkbox on selection-screen for with or without total line.
PARAMETERS: p_check AS CHECKBOX.
<li>Now set the below on based on checkbox value
IF p_check = 'X'. "Lets say without total line.
wa_layout-no_totalline = 'X'.
ENDIF.
<li>Now pass wa_layout through REUSE* function module.
Thanks
Venkat.O -
Report form (rows covert in column)
there are two table in scott schema
emp:
empno ename deptno
12121 dfsaf 10
78782 adfsd 20
dept:
deptno
10 marketing
20 finance
30 advertising
i want the out put like this
deptno10 deptno 20
empno 121211 41744
means to convert the row of dept table into column into any other table. Can i do this
please help me eitther in sql or jdeveloper.
thanks
nullHi,
Please dont keep the formula in the data range. I would suggest you can add an extra row and keep the formula in it. However, make sure that this added row is not a part of the data range.
Hope this helps. -
How to make tooltip highlight extra row data on a table
I have a table in a declarative component.
It only has 4 columns but there is a lot of extra data I would like to display when the user hovers over a row. You can see in the 'shortDesc' property I've added this but it doesn't work. Any help would be greatly appreciated.
<af:table value="#{attrs.idmkr_table_model.collectionModel}"
var="row"
rows="#{attrs.idmkr_table_model.rangeSize}"
emptyText="#{attrs.idmkr_table_model.viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{attrs.idmkr_table_model.rangeSize}"
rowBandingInterval="0"
filterModel="#{attrs.idmkr_query_model.queryDescriptor}"
queryListener="#{attrs.idmkr_query_model.processQuery}"
filterVisible="false" varStatus="vs"
binding="#{attrs.idmkr_table_binding.myTable}"
id="addr_addressees" rowSelection="multiple"
columnStretching="last"
width="100%"
shortDesc="#{row['Address1']}, #{row['Address2']}, #{row['City']}, #{row['State']}, #{row['Postalcode2']}, #{row['Email']}, #{row['Phone']}, #{row['Fax']}"
styleClass="AFStretchWidth">
<af:column headerText="Name" sortable="true" sortProperty="Lastname" filterable="true">
<af:outputText value="#{row['Lastname']}"/>
</af:column>
<af:column headerText="Type" sortable="true" sortProperty="Type" filterable="true">
<af:outputText value="#{row['Type']}"/>
</af:column>
<af:column headerText="Role" sortable="true" sortProperty="Role" filterable="true">
<af:outputText value="#{row['Role']}"/>
</af:column>
<af:column headerText="Distribution" sortable="true" sortProperty="Preferreddist" filterable="true">
<af:outputText value="#{row['Preferreddist']}"/>
</af:column>
</af:table>Hey Frank, thank you very much, but that leads to a problem. Our team had Duncan Mills come to our location who said not to use javascript. Doesn't clientlistener call a javascript method? If there is a way to implement this without javascript I would prefer to do that. If javascript is our only option then I will do that.
Thx. -
Count the no. of rows in a column
I want to count the no. of rows in APR_QTY column that are not equal to zero.
SELECT DISTINCT
SUPP_NAME,
ITEM_NAME,
(CASE WHEN BH_CAL_PERIOD=4 THEN TO_NUMBER(BI_QTY || '.' || BI_QTY_LS) ELSE 0 END)APR_QTY,
(CASE WHEN BH_CAL_PERIOD=4 THEN BI_RATE ELSE 0 END)APR_RATE,
(CASE WHEN BH_CAL_PERIOD=5 THEN TO_NUMBER(BI_QTY || '.' || BI_QTY_LS) ELSE 0 END)MAY_QTY,
(CASE WHEN BH_CAL_PERIOD=5 THEN BI_RATE ELSE 0 END)MAY_RATE,
(CASE WHEN BH_CAL_PERIOD=6 THEN TO_NUMBER(BI_QTY || '.' || BI_QTY_LS) ELSE 0 END)JUNE_QTY,
(CASE WHEN BH_CAL_PERIOD=6 THEN BI_RATE ELSE 0 END)JUNE_RATE,
(CASE WHEN BH_CAL_PERIOD=7 THEN TO_NUMBER(BI_QTY || '.' || BI_QTY_LS) ELSE 0 END)JUL_QTY,
(CASE WHEN BH_CAL_PERIOD=7 THEN BI_RATE ELSE 0 END)JUL_RATE
FROM
OM_SUPPLIER,
OM_ITEM,
OT_BILL_HEAD,
OT_BILL_ITEM,
OT_BILL_ITEM_TED
WHERE BI_BH_SYS_ID = BH_SYS_ID
AND SUPP_CODE = BH_SUPP_CODE
AND ITEM_CODE = BI_ITEM_CODE
AND BH_SYS_ID = ITED_H_SYS_ID
AND BI_SYS_ID = ITED_I_SYS_ID
AND BH_TXN_CODE='SBRLRAW'
GROUP BY BH_CAL_PERIOD,BH_TXN_CODE,SUPP_NAME,ITEM_NAME,BI_RATE,BI_QTY,BI_QTY_LS
ORDER BY ITEM_NAME
Message was edited by:
yogeshylSelect sum(decode(apr_qty,0,0,1)) as cnt_apr_qty
from ... -
PL/SQL-find out extra rows present in table by comparing 2 similar tables
Hi, can any one give me an idea to find out the extra rows present in table by comparing 2 similar tables using pl/sql.
REQUIREMENT::i am working on the upgrade environment.my previous database has some tables and having data.Now functional folks are adding some new data to the existing tables for the upgrade database.I need to identify that new rows which are added by them.
for this , i created name table with 2 columns n,n1 which contains the table names.
Table Name:Name
columns:n n1
a ax
b bx
c cx
a,b c........are the table names which are in the previous database environment.(approx >1500 tables)These tables having data.
ax,bx,cx..........table names which are in the upgrade environment contains the extra data which is added by the functional folks.
a&ax,b&bx.................(approx 1500 tables) are having same structure except some of them.
Now i want to write a pl/sql program that reads both table names a&ax from name table and then by comparing the rows of a&ax ,i need to find out the extra rows present in the ax table to store that in different place.
Example:
a table
id name
1 co
2 wi
3 il
ax table
id name
1 co
2 wi
3 il
4 va
5 ca
Here i need to find out the difference b/n the 2 tables ,the extra rows id 4,5 and place it some where.this is just for demo, is this you mean?
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
2 FROM EMP e full outer join DEPT d
3* on d.DEPTNO= e.DEPTNO
SQL> /
EMPNO ENAME EMP_DEPTNO DEPT_DEPTNO DNAME
7934 MILLER 10 10 ACCOUNTING
7839 KING 10 10 ACCOUNTING
7782 CLARK 10 10 ACCOUNTING
snipp........
7521 WARD 30 30 SALES
7499 ALLEN 30 30 SALES
156 1
12 1
40 OPERATIONS
90 LOGISTIC
18 rows selected.
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
2 FROM EMP e left outer join DEPT d
3* on d.DEPTNO= e.DEPTNO
SQL> /
EMPNO ENAME EMP_DEPTNO DEPT_DEPTNO DNAME
7934 MILLER 10 10 ACCOUNTING
7839 KING 10 10 ACCOUNTING
7782 CLARK 10 10 ACCOUNTING
7902 FORD 20 20 RESEARCH
snipp..................
7654 MARTIN 30 30 SALES
7521 WARD 30 30 SALES
7499 ALLEN 30 30 SALES
156 1
12 1
16 rows selected.
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
2 FROM EMP e[b] right outer join DEPT d
3* on d.DEPTNO= e.DEPTNO
SQL> /
EMPNO ENAME EMP_DEPTNO DEPT_DEPTNO DNAME
7369 SMITH 20 20 RESEARCH
7499 ALLEN 30 30 SALES
7521 WARD 30 30 SALES
7566 JONES 20 20 RESEARCH
snipp......................
7902 FORD 20 20 RESEARCH
7934 MILLER 10 10 ACCOUNTING
40 OPERATIONS
90 LOGISTIC
16 rows selected. -
AdvancedDataGridRendererProvider spanning Grouping Column
Hi,
I am trying to span just the Grouping Column.
Sample Data:
Southwest
Northern California Lauren Ipsum
Arizona Dana Binn
The above data is displayed in AdvancedDataGrid. What I want is when I loan, I want to span the row where Southwest is displayed with one Renderer where it shows a Text Southwest and then a ComboBox.
How can I span all three columns for that perticular row? I looked into AdvancedDataGridRendererProvider, but I can't seem to figure out how to do the Grouping Column. What ever I try, it spans the leaf notes, but not the Southwest. Does anyone know how to archieve this? Thanks.Hi,
I was able to span the Grouping Column, but I am loosing the Children and the renderer is only rendering in the first cell, not all three columns even though the all three columns are spanned.
This is what I have done in summary to span the Grouping row.
var rp : AdvancedDataGridRendererProvider = new AdvancedDataGridRendererProvider();
rp.renderer = new ClassFactory(TestRenderer);
// rp.dataField = "Region";
rp.columnIndex = 0;
rp.columnSpan = 2;
rp.depth = 1;
If I uncomment the line above I loose this spanning and it just shows the hierarchical data with the default renderer and it does not even render my renderer. Please help. Thanks.
Full code:
testAdvancedDataGridSpanningColumn.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.containers.HBox;
import mx.controls.advancedDataGridClasses.AdvancedDataGridRendererProvider;
import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
import mx.collections.GroupingCollection;
import mx.collections.GroupingField;
import mx.collections.Grouping;
import mx.collections.ArrayCollection;
[Bindable]
private var dpFlat : ArrayCollection = new ArrayCollection([
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},
{Region:"Southwest", Territory:"Central California",
Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},
{Region:"Southwest", Territory:"Nevada",
Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},
{Region:"Southwest", Territory:"Northern California",
Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
{Region:"Southwest2", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},
{Region:"Southwest2", Territory:"Southern California",
Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
{Region:"Southwest2", Territory:"Southern California",
Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000, Test:"Worked"}
[Bindable]
public var myGCol1 : GroupingCollection = new GroupingCollection();
private var myGrp : Grouping = new Grouping();
private function initDG() : void
// Initialize the GroupingCollection instance
myGCol1.source = dpFlat;
// The Grouping instance defines the grouping fields
// in the collection, and the order of the groups
// in the hierarchy.
myGrp.fields = [new GroupingField("Region")];
// The grouping property contains a Grouping instance
myGCol1.grouping = myGrp;
// Specify the GroupedCollection as the data provider for
// the AdvancedDataGrid control.
myADG2.dataProvider = myGCol1;
// Refresh the display
myGCol1.refresh();
private function createColumns() : void
var cols: Array = myADG2.columns;
cols.push( new AdvancedDataGridColumn("Region"));
cols.push( new AdvancedDataGridColumn("Territory"));
cols.push( new AdvancedDataGridColumn("Territory_Rep"));
myADG2.columns = cols;
var testTypes : ArrayCollection = new ArrayCollection();
testTypes.addItem("test 1");
testTypes.addItem("test 2");
var rend : TestRenderer = new TestRenderer();
rend.types = testTypes;
var rp : AdvancedDataGridRendererProvider = new AdvancedDataGridRendererProvider();
rp.renderer = new ClassFactory(TestRenderer);
// rp.dataField = "Region";
rp.columnIndex = 0;
rp.columnSpan = 2;
rp.depth = 1;
myADG2.rendererProviders.push(rp);
myADG2.validateNow();
]]>
</mx:Script>
<mx:Panel
title="Advanced DataGrid Control Example"
height="75%"
width="75%"
layout="horizontal"
paddingTop="10"
paddingBottom="10"
paddingLeft="10"
paddingRight="10">
<mx:AdvancedDataGrid
id="myADG2"
width="100%"
height="100%"
creationComplete="initDG()" initialize="createColumns();" sortExpertMode="true" showHeaders="false" >
</mx:AdvancedDataGrid>
</mx:Panel>
</mx:Application>
TestRenderer.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox
xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
[Bindable]
public var types : ArrayCollection;
override public function set data(value : Object) : void
if(value != null)
super.data = value;
// Dispatch the dataChange event.
dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
]]>
</mx:Script>
<mx:Label text="{data.GroupLabel}" />
<mx:ComboBox dataProvider="{types}" />
</mx:HBox> -
Select extra row without using UNION ALL in pl/sql
Hi,
Can anyone tell me how to select extra row without using UNION or UNION ALL in pl/sql. Actually I want to have my o/p of query as partitioned by designation and ordered by salary and than one extra row which will contain the highest salary in a particular salary. My table has first_name,emp_id,designation and salary column. And I wnt the o/p as.
Mohinish,12212,SI,46000
Ram,11212,SSI,47000
Shyam,12133,SI,48000
Rick,9898,SI,46000
Rocky,12312,SSI,56000
Sariq,23948,SI,43000
Suman,12789,HR,49000
Sampy,12780,SI,46000
Parna,11111,HR,50000
Now the o/p should be.
Mohinish,12212,SI,46000
Rick,9898,SI,46000
Sariq,23948,SI,43000
Shyam,12133,SI,48000
Shyam,12133,SI,48000
Ram,11212,SSI,47000
Rocky,12312,SSI,56000
Rocky,12312,SSI,56000
Suman,12789,HR,49000
Parna,11111,HR,50000
Parna,11111,HR,50000
Thanks in AdvanceYou don't have to do a UNION or UNION ALL in PL/SQL but you would need to in SQL to get the desired output:
with data_recs
as (select 'Mohinish' first_name,12212 emp_id,'SI' designation,46000 salary from dual union
select 'Ram',11212,'SSI',47000 from dual union
select 'Shyam',12133,'SI',48000 from dual union
select 'Rick',9898,'SI',46000 from dual union
select 'Rocky',12312,'SSI',56000 from dual union
select 'Sariq',23948,'SI',43000 from dual union
select 'Suman',12789,'HR',49000 from dual union
select 'Sampy',12780,'SI',46000 from dual union
select 'Parna',11111,'HR',50000 from dual)
select first_name, emp_id, designation, salary from data_recs union all
select s.first_name, s.emp_id, s.designation, s.salary
from (select first_name,
emp_id,
designation,
salary,
row_number() over (partition by designation order by salary desc) high_salary
from data_recs
order by designation, salary) s
where s.high_salary = 1
order by designation, salary;
FIRST_NAME EMP_ID DESIGNATION SALARY
Suman 12789 HR 49000
Parna 11111 HR 50000
Parna 11111 HR 50000
Sariq 23948 SI 43000
Rick 9898 SI 46000
Mohinish 12212 SI 46000
Sampy 12780 SI 46000
Shyam 12133 SI 48000
Shyam 12133 SI 48000
Ram 11212 SSI 47000
Rocky 12312 SSI 56000
Rocky 12312 SSI 56000 -
Print Row Numbers and Column Letters
How do you tell Numbers to print the Row numbers and Column letters? This was very simple in Appleworks (print dialog box had that option). Can't find it in Numbers though.
Here is a script doing all the job for us.
Just select one or several cells in a table and run the script.
It duplicates it, add an header row, an header column, insert the needed labels and fill the other cells with a formula grabbing the contents of the original table.
--[SCRIPT build a table with headers]
Enregistrer len tant que Script: build a table with headers.scpt
déplacer le fichier créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Selectionner une cellule dans la table à dupliquer
menu Scripts > Numbers > build a table with headers
Le script duplique la table et crée des en-têtes de lignes et colonnes.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
+++++++
Save the script as Script: build a table with headers.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select a range of cells in the table to 'duplicate'
menu Scripts > Numbers > build a table with headers
The script duplicate the table and inserts columns/rows headers.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
--=====
Yvan KOENIG (VALLAURIS, France)
2009/09/19
--=====
property theApp : "Numbers"
--=====
my activateGUIscripting() (* to be sure than GUI scripting will be active *)
set {d_Name, s_Name, t_Name, r_Name} to my getSelection()
if r_Name is missing value then
if my parleAnglais() then
error "No selected cells"
else
error "Il n'y a pas de cellule sélectionnée !"
end if
end if
set new_Table to t_Name & "_#"
my duplicateTable(s_Name, t_Name, new_Table)
set delim to my getLocalizedDelimiter()
(* grab localized function names and add an open parenthesis at end *)
set IF_loc to my getLocalizedFunctionName("Numbers", "IF") & "("
set CHAR_loc to my getLocalizedFunctionName("Numbers", "CHAR") & "("
set INT_loc to my getLocalizedFunctionName("Numbers", "INT") & "("
set MOD_loc to my getLocalizedFunctionName("Numbers", "MOD") & "("
set INDIRECT_loc to my getLocalizedFunctionName("Numbers", "INDIRECT") & "("
set ADDRESS_loc to my getLocalizedFunctionName("Numbers", "ADDRESS") & "("
(* grab localized function names and add a couple of parenthesis at end *)
set ROW_loc to my getLocalizedFunctionName("Numbers", "ROW") & "()"
set COLUMN_loc to my getLocalizedFunctionName("Numbers", "COLUMN") & "()"
tell application "Numbers" to tell document d_Name to tell sheet s_Name to tell table new_Table
if column count = 256 then
if my parleAnglais() then
error "Oops, already 256 columns !"
else
error "Désolé, il y a déjà 256 colonnes !"
end if
end if
if row count = 65536 then
if my parleAnglais() then
error "Oops, already 65536 rows !"
else
error "Désolé, il y a déjà 65536 lignes !"
end if
end if
try
add row above row 1
on error
if my parleAnglais() then
error "Oops, already five header row !"
else
error "Désolé, il y a déjà cinq rangs d’en tête !"
end if
end try
try
add column before column 1
on error
if my parleAnglais() then
error "Oops, already five header columns !"
else
error "Désolé, il y a déjà cinq rangs d’en tête !"
end if
end try
set nbr to row count
set nbc to column count
(* =IF(COLUMN()<28,CHAR(COLUMN()63),CHAR(INT((COLUMN()-2)/26)+64)&CHAR(MOD(COLUMN()-2,26)65)) *)
set theFormula to "=" & IF_loc & COLUMN_loc & "<28" & delim & CHAR_loc & COLUMN_loc & "+63)" & delim & CHAR_loc & INT_loc & "(" & COLUMN_loc & "-2)/26)+64)&" & CHAR_loc & MOD_loc & COLUMN_loc & "-2" & delim & "26)+65))"
tell row 1
repeat with c from 2 to nbc
set value of cell c to theFormula
end repeat
end tell -- row 1
(* =ROW()-1 *)
set theFormula to "=" & ROW_loc & "-1"
tell column 1
repeat with r from 2 to nbr
set value of cell r to theFormula
end repeat
end tell -- column 1
(* =INDIRECT(ADDRESS(ROW()-1,COLUMN()-1,,,"Tableau 2")) *)
set theFormula to "=" & INDIRECT_loc & ADDRESS_loc & ROW_loc & "-1" & delim & COLUMN_loc & "-1" & delim & delim & delim & quote & t_Name & quote & "))"
repeat with r from 2 to nbr
repeat with c from 2 to nbc
set value of cell r of column c to theFormula
end repeat -- with c
end repeat -- with r
end tell -- Numbers
--=====
Set the parameter delimiter which must be used in Numbers formulas
on getLocalizedDelimiter()
if character 2 of (0.5 as text) is "." then
return ","
else
return ";"
end if
end getLocalizedDelimiter
--=====
on getLocalizedFunctionName(theApp, x)
local p2bndl
set p2bndl to (path to application support as text) & "iWork '09:Frameworks:SFTabular.framework:Versions:A:Resources:"
return my getLocalizedName(theApp, x, p2bndl)
end getLocalizedFunctionName
--=====
on getLocalizedName(a, x, f)
tell application a to return localized string x from table "Localizable" in bundle file f
end getLocalizedName
--=====
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
tell application "Numbers" to tell document 1
repeat with i from 1 to the count of sheets
tell sheet i
set x to the count of tables
if x > 0 then
repeat with y from 1 to x
try
(selection range of table y) as text
on error errMsg number errNum
set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
return {theDoc, theSheet, theTable, theRange}
end try
end repeat -- y
end if -- x>0
end tell -- sheet
end repeat -- i
end tell -- document
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on isItAsheet(s)
try
tell application "Numbers" to tell document 1
count of tables of sheet s (*
Post an error if s is not a sheet *)
end tell
return true
on error
return false
end try
end isItAsheet
--=====
on activateGUIscripting()
tell application "System Events"
if not (UI elements enabled) then set (UI elements enabled) to true (* to be sure than GUI scripting will be active *)
end tell
end activateGUIscripting
--=====
on duplicateTable(sourceSheet, sourceTable, newName)
local lesFeuilles, lesTables1, found, listOfRows, cor, i, isSourceSheet, nameI, j, lesTables2
tell application "Numbers"
activate
tell document 1
set lesFeuilles to name of sheets
if sourceSheet is in lesFeuilles then
tell sheet sourceSheet to set lesTables1 to name of tables
if sourceTable is not in lesTables1 then
if my parleAnglais() then
error "The sheet “" & sourceTable & "” of sheet “" & sourceSheet & "” is unavailable ! "
else
error "La table “" & sourceTable & "” de la feuille “" & sourceSheet & "” n'existe pas ! "
end if
end if -- sourceTable is not
else
if my parleAnglais() then
error "The sheet “" & sourceSheet & "” is unavailable ! "
else
error "La feuille “" & sourceSheet & "” n'existe pas ! "
end if
end if -- sourceSheet is in
end tell -- document
end tell -- application
if newName is not in lesTables1 then (*
Now, an ugly workaround to duplicate the sheet *)
set isOS4 to (system attribute "sys2") < 5
tell application "System Events" to tell application process "Numbers"
set docWindow to false (* CAUTION, an inspector ("AXFloatingWindow") or a Find/Search ("AXDialog") window may be open *)
repeat with i from 1 to (count of windows)
if subrole of window i is "AXStandardWindow" then
set docWindow to i (* got the document's window *)
exit repeat
end if
end repeat
if docWindow is not false then
tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window docWindow
select row 1
set value of attribute "AXFocused" to true
set found to false
set listOfRows to name of static text of every row
set cor to count of rows (* equal count of listOfRows *)
if isOS4 then (*
for mac Os X 10.4.11
CAUTION, listOfRows it's a list of lists !
{{"Feuille 2"}, {"Tableau 1"}, {"theSheet"}, {"Feuille 1"}, {"Tableau 2"}, {"Clément"}, {"Feuille 4"}} *)
repeat with i from 1 to cor (*
Scan the thumbnails *)
set nameI to item 1 of item i of listOfRows
set isSourceSheet to (sourceSheet = nameI) and my isItAsheet(nameI)
if isSourceSheet then
select row i
if (i < cor) and not my isItAsheet(item 1 of item (i + 1) of listOfRows) then (*
Here we may scan the thumbnails of tables of sourceSheet *)
repeat with j from i + 1 to i + (count of lesTables1)
if sourceTable = item 1 of item j of listOfRows then
select row j
set found to true
exit repeat
end if -- sourceTable
end repeat
else
if my parleAnglais() then
error "The sheet “" & sourceTable & "” of sheet “" & sourceSheet & "”" & return & " is not revealed in thumbnails ! "
else
error "La table “" & sourceTable & "” de la feuille “" & sourceSheet & "”" & return & " n'est pas affichée dans les vignettes ! "
end if -- my parleFrancais
end if -- (i < cor)
end if -- isSourceSheet
if found then exit repeat
end repeat -- i
else (*
for mac Os X 10.5.x
CAUTION, listOfRows is a list of lists !
{{}, {"Tableau 1"}, {"theSheet"}, {}, {"Tableau 2"}, {"Clément"}, {}}
With 10.5.x, the names of sheets are empty *)
repeat with i from 1 to cor
set isSourceSheet to (class of UI element 1 of row i is group) and (get value of static text 1 of group 1 of row i) is sourceSheet
if isSourceSheet then (*
Here we may scan the thumbnails of tables of sourceSheet *)
if value of UI element 1 of group 1 of row i is 0 then (*
reveal the tables's thumbnails and adjust the list accordingly *)
click UI element 1 of group 1 of row i (* click the black triangle to reveal tables *)
delay 0.1
set listOfRows to name of static text of every row (* update the list accordingly *)
end if -- value of UI…
repeat with j from i + 1 to i + (count of lesTables1)
if sourceTable = item 1 of item j of listOfRows then
select row j
set found to true
exit repeat
end if -- sourcetable
end repeat -- with j
end if -- isSourceSheet
if found then exit repeat
end repeat -- with i
end if -- check OS
end tell -- outline …
keystroke "d" using command down
end if -- docWindow
end tell -- System Events…
if docWindow is not false then (*
Rename the new table according to the passed name: newTable *)
tell application "Numbers" to tell document 1 to tell sheet sourceSheet
set lesTables2 to name of tables
repeat with i in lesTables2
if i is not in lesTables1 then (*
Here i is the name of the newly created table *)
set name of table i to newName
exit repeat
end if
end repeat
end tell
end if -- docWindow
end if -- newName is not…
end duplicateTable
--=====
on parleAnglais()
local z
try
tell application theApp to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) samedi 19 septembre 2009 17:33:59
Maybe you are looking for
-
How can I initialize all TabNavigator Tabs upon a state change?
Here's the basic goal. I want to provide two views to the user that display the same panels. I configured each view as a separate state but I am having trouble initializing each of the tab views since they are only created by Flex when the user first
-
Error while setting up Oracle Serice Registery
I have setup Oracle Service Registery. The installtion went sucessfully without any error. The registery.war got sucessfully installed in the Weblogic server. The UDDINODE Table space and UDDIUSER user got created in the Database. But while running t
-
Help - Nokia C200 - USB Cable Issue
Hello! Friends... First I Thank to ajaydavidson for my previous probem.. & Now I find some difficult when I am connection with my USB Cable to My Nokia C200. I ll post the Screen Shot, Then it bit clear to solve this... Click here! Error: Hi-Speed
-
IPod 2G doesn't prepare for restore!
I found this iPod not long ago so I bought a charger for it, I had charging problems, but I think I fixed them and the iPod had someone else's things so I decided to restore it so I got iTunes and connected the iPod to my computer, iTunes recognized
-
How do i stop the Icloud music from playing on my iPhone? I have unchecked those songs before syncing my phone but they still show up on my phone and i don't want to hear them. Is there a way to turn that off? i have iTunes match turned off. i have