$objPHPExcel->setActiveSheetIndex($i)->getCell('A' . $j)
->getHyperlink('mytext')
->setUrl('http://abc.com');
i am trying to link a specific part of text in cell, but its linking to a whole cell, is there any solution to do it?
OR
if i do it with multiple cells, is there any way to apply width of specific row in a sheet?
e.g.
ROW1 CELL1 CELL2 CELL3 CELL4
ROW2 ----CELL1----CELL2----
ROW3 ----CELL1----CELL2----
ROW4 ----CELL1----CELL2----
Can be achieved by using below code.
$objPHPExcel->setActiveSheetIndex($i)->SetCellValue(A1, 'mytext');
$objPHPExcel->setActiveSheetIndex($i)->getCell(A1)->getHyperlink()->setUrl('http://abc.co');
Related
I tried to read all posts like this but I did not succeed.
I need to extract tables of different layouts from a single sheet in excel, for each sheet of the file.
Any help or ideas that can be provided would be greatly appreciated.
A sample of the datafile and it's structure can be found Here
I would use readxl. The code below reads just one sheet, but it is easy enough to adapt to read multiple or different sheets.
First we just want to read the sheet. Obviously you should change the path to reflect where you saved your file:
library(readxl)
sheet = read_excel("~/Downloads/try.xlsx", col_names = LETTERS[1:12])
If you didn't know you had 12 columns, then using read_excel without specifying the column names would give you enough information to find that out. The different tables in the sheet are separated by one or two blank rows. You can find the blank rows by testing each row to see if all of the cells in that row are NA using the apply function.
blanks = which(apply(sheet, 1, function(row)all(is.na(row))))
blanks
> blanks
[1] 7 8 17 26 35 41 50 59 65 74 80 86 95 98
So you could extract the first table by taking rows 1--6 (7 - 1), the second table by taking rows 9--16 and so on.
I am doing a queuing system. Now i need to display the queuing number in a 4 X 2 table like:
A1 has an earlier queue time.
A1 | A5
A2 | A6
A3 | (empty cell)
A4 | (empty cell)
The requirement:
first 4 items will be listed vertically in the FIRST COLUMN, then the remaining 4 items will be listed in SECOND COLUMN.
if only 6 items in the queue, leave the last 2 cells empty.
I have tried RepeatDirection.Vertical when using Datalist, but the number of rows cannot be set to 4.
Are there better ways to achieve the format?
You need to set the RepeatColumns property to 4.
If RepeatDirection is Vertical (which is the default), the items are listed vertically in the first COLUMN until the number of items reaches RepeatColumns, then wrapped to the second COLUMN.
Think it as a 2 x 4 table that rotates 90 degrees.
I have a data in excel in the format as shown below. The user may add comments to the score column using 'Insert Comment' option in excel. I would like to extract the comments added to scores column and put it in the column 'Comments'. Is this possible? Can you please help?
Report Component Score Comments
R1 C1 1
R2 C2 2
R3 C3 3
R4 C4 4
R5 C5 5
Here is the code I have written so far. Not sure how to proceed further. PLease help.
require(readxl)
read_excel("Testfile01.xlsx")
I have yet to see this kind of functionality in read_excel, but in the mean time, you could perhaps write comments into cell content using just prior to importing the file into R.
From ExtendOffice:
Function GetComments(pRng As Range) As String
'Updateby20140509
If Not pRng.Comment Is Nothing Then
GetComments = pRng.Comment.Text
End If
End Function
You can then use GetComments function, e.g. =GetComments(A1).
Have a question on using xtable with Sweave when there are multiple columns. A table I am working on has about 25 columns and 5 rows. The exact number of columns is not known as that is dynamic.
When I run say,
table1 <- table (df$someField)
I get a table that essentially exceeds the page length.
ColA ColB ColC
---------------------------
RowA 1 2 3 ......
RowB 3 4 6 ......
If a do a xtable on this, and run it through Sweave,
xtable(table1, caption="some table")
it overflows.
What I am looking for is something like,
ColA ColB ColC
---------------------------
RowA 1 2 3
RowB 3 4 6
ColD ColE ColF
---------------------------
RowA 11 9 34
RowB 36 8 65
with the \hline etc markups. Basically, split the xtable into parts by say 5 columns per "sub-table".
I am also running this in a batch job, so I won't be able to make changes to individual files, whatever the solution it has to be able to be generated by running Sweave on the Rnw file.
Thanks in advance,
Regards,
Raj.
Here's an example of this from ?latex.table.by in the taRifx package. You can brew something similar using longtable in LaTeX and use the latex.table.by code as a prototype.
my.test.df <- data.frame(grp=rep(c("A","B"),10),data=runif(20))
library(xtable)
latex.table.by(my.test.df)
# print(latex.table.by(test.df), include.rownames = FALSE, include.colnames = TRUE, sanitize.text.function = force)
# then add \usepackage{multirow} to the preamble of your LaTeX document
# for longtable support, add ,tabular.environment='longtable' to the print command (plus add in ,floating=FALSE), then \usepackage{longtable} to the LaTeX preamble
Regardless, the longtable package in LaTeX is the key.
Edit: It appears you have too many columns not too many rows. In that case, first try landscaping just that page.
In the header:
\usepackage{lscape}
Around your table:
\begin{landscape}
...
\end{landscape}
Or just use sidewaystable.
If your table is too wide to fit in one page, try the supertabular package, which from the description sounds like it might handle breaking over multiple pages based on width (but I've never used it so can't be sure).
i using datalist control where i am displaying images under it. that is( 6 columns * 5 rows)
for thati have property repeat direction is "horiztonal" .
like the above design i need perform in listview Control (i.e )
display like this( here 1,2 are data after 6 data is displayed 7th data start from second row)
1 2 3 4 5 6
7 8 10 11 12 13
any help would be great thank you
A ListView is better suited for this.
EDIT
You can insert basic HTML in the ItemTemplate and use the binding syntax described here:
https://web.archive.org/web/20211020150712/https://www.4guysfromrolla.com/articles/010208-1.aspx
Try RepeatColumns to specify the item count in a row like this :
DataList1.RepeatColumns = 6;
DataList1.RepeatDirection = RepeatDirection.Horizontal;