I am using Spreadsheet::WriteExcel. I want to merge two cells and give the hyperlink to the content inside merged cells.
I have tried like this.
$Log_Sheet->merge_range('D2:E2','Home',$MergedFormat);
$Log_Sheet->write_url('D2','internal:sheet1!A1');
This is working fine but when I try to open a file it shows a warning saying File error: data may have been lost. This occurs because D2 cell is being overwritten.
How can I merge cells and give hyperlink in one call?
I can't promise this works on Spreadsheet::WriteExcel, but it does on Excel::Writer::XLSX. I'd encourage you to try it on Spreadsheet::WriteExcel.
With merged ranges, once you declare a format, you need to continue using it for that range and never use it for non-merged ranges. So, if you take your code and add the tag and the format object:
$Log_Sheet->merge_range("D2:E2", 'Home', $MergedFormat);
$Log_Sheet->write_url('D2', 'internal:sheet1!A1', 'Click Me!', $MergedFormat);
It does appear to work... on Excel::Writer::XLSX. Sorry to keep referencing that.
Alternatively, per the previous post (File Error:data may have been lost while giving hyperlinks), you can also use the built-in Hyperlink function within Excel:
my $merged = $workbook->add_format();
$worksheet->merge_range("A10:A11",
qq{=hyperlink("#'Sheet3'!A1","Click Here!")},
$merged);
Related
I have an excel template that has preset formulas, then have my wpf application fills in data in other sheets then the preset formulas takes the data from the other sheet and shows it on the main page.
The problem is when I automatically PDF the excel most formulas go through but other's give me a System.Object[][] or some other errors. But when I access the excel file with the dataset it works.
The difference between the formulas that go through and the ones that don't are the ones that have an if() statement to remove all non zeroes in a range like this.
=TEXTJOIN("
", TRUE, TEXT(IF(Details!O:O>0,Details!O:O,""), "HH:MM"))
Functions like this works:
=TEXTJOIN("
",TRUE,Details!D:D)
How do I get Spire.xls to PDF the right format?
As you tested the Excel file and found it working fine, the problem is likely located inside the Spire rendering.
You can of course report a bug over there but that might not get resolved instantly.
You may want to try applying a number format to the cells for zero values instead of using that if part in the formula.
Something like this could do when writing with ClosedXML if implemented correctly by Spire:
worksheet.Cell(row, column).Style.NumberFormat.Format = "#,##0;[Red]-#,##0;\"\";#";
Formating possibilities are somewhat documented by Microsoft, take a look over there.
I've been saving Google Sheets to Excel without any problems for a while. These sheets have always successfully saved and opened in Excel with the importrange function. However, recently it hasn't been successfully saving correctly.
It used to just have the static value (e.g, 40). There used to be an IFERROR in the first cell in the header row but now it exists in every single cell.
E.g, each cell would have something like this:
=IFERROR(__xludf.DUMMYFUNCTION(importrange(blahblah)),"40").
DUMMYFUNCTION throws an error and "40" is returned as a result. but "40" is a string, not an integer which messes up all my formulas.
I also know this isn't an Excel issue because OpenOffice is doing the same thing with the file.
I'm pretty sure this would be a bug because why would it be working for months and then suddenly stop working?
What should I do?
I'm thinking it's a bug too.
Workarounds
On Excel
Copy and paste as values only the ranges with IFERROR(__xludf.DUMMYFUNCTION(..., then use Excel's UI tools to convert numbers shown as text to numbers.
Selectively remove quotes on the IFERROR second argument of the cells causing problems
Remove =IFERROR(__xludf.DUMMYFUNCTION(),"value") except value (we could use Excel's built-in FIND & REPLACE for this)
On Google Sheets
Use Copy > Paste as values only on the range areas having formulas with non-compatible functions like IMPORTRANGE, QUERY, FILTER, etc.
If you only need the values, download it as CSV instead of XLSX
IMPORTANT
In order to help to prioritize this issue, send feedback to Google. To do this open a Google Sheets spreadsheet, click on Help > Report a problem, then fill the feedback form and submit it.
Related stuff
I posted 5 small articles about this in Spanish. You could find them listed on https://www.rubenrivera.mx/p/descargar-hcg-excel.html.
We accidentally created a workaround for this bug with a different sheet that was just set up like this.
This works when you IMPORTRANGE into another Google Sheet. We are doing it into a Google Sheet with a single worksheet - haven't tried it with multiple.
It's going to sound a little nuts but it works for us.
In the first cell of your import range put a hyperlink in the original document you are importing from. This is in the first cell of the import range. We linked it to a worksheet in the original document. It has worked and failed with an external link. With an external link it worked when I linked it to an internal link, then changed it. But when I deleted the cell and just straight linked it to an external URL it didn't work.
Then #timbo was right - put data validation in. This can be in part of the document that isn't being imported into the second sheet. I put it in the first line of the import range but outside what I was importing. It might have to be the first line. I just put a date in one cell, then in the next cell data > data validation > then choose that one date as the data range.
For aesthetics I have hidden the first row in one Google Sheet I am importing into. In another I made the first cell link the title of the sheet and put the data validation outside the import range. Both of these work.
Let me know if this works for you.
Until this bug is fixed, a workaround is to put a data validation (Data > Data Validation) on the imported data (Any kind of data validation will do).
I am currently using this formula: =SUMPRODUCT(1*(YEAR(E2:E81)=2018)) However i want to run this formula on a summary tab and the data will be on another sheet called "BRIDGE". I tried =SUMPRODUCT(BRIDGE!1*(YEAR(E2:E81)=2018)) but I get an error
Rather than putting the sheet reference as you have, put it prior to the range instead.
=SUMPRODUCT(1*(YEAR(BRIDGE!E2:E81)=2018))
I want to reference an external workbook that is open. If I type =path\[file] directly into the cell (even though I am still asked to 'Update Values',) I am able to get the data I require. However, I am using INDIRECT because the name of the file changes everyday (date). So, I am using CONCATENATE to create a filename daily and then using INDIRECT to the cell where the concatenated formulas is. If you paste values to see what is being generated formula, it is exactly the same formula as above, =path\[file]. However, I continue to only get #REF! error.
I read through this, https://support.office.com/en-us/article/control-when-external-references-links-are-updated-87861952-ca9d-4d2a-a986-4d672c908d0d, and I still can not figure it out. I had it working on my computer at home last night but today and work it is giving me trouble.
To clarify, the formula that I am trying to get to work looks like this =INDIRECT("'"&CONCATENATE($F$129,$F$130,F95)) which worked yesterday at home. Can someone lead me in the right direction?
EDIT:
I have tried two options, =INDIRECT(F121) and =INDIRECT("'"&F121). The contents of F121 have been =CONCATENATE("'",F191,F192,F157) and =CONCATENATE(F191,F192,F157), respectively. I have also tried =CONCATENATE("'",F191,F192,F157) in the destination cell. F191 = [Liquidity Risk Dashboard v2.03 -, F192 = =TEXT(E3,"yyyymmdd")&"]", and F157 = Calculations'!D122. If I write ='[BMI Liquidity Risk Dashboard v2.03 - 20170105]Calculations'!D122 am asked to update values but, 100% have both workbooks upon in same instance
If I understand what you really have in your cells, the problem is that you are not properly naming the source workbook.
Try changing
F192: =TEXT(E3,"yyyymmdd")&".xlsb]"
Replace .xlsb with whatever the file extension really is for your file. (eg: .xlsx, .xlsm, .xls)
I have two workbooks:
WorkbookToUpdate.xls
Workbook_for_20130901.xls
In the first workbook I have the following:
A1 ='[Workbook_for_20130901]Sheet1'!$C5
Now a month goes by and I want to update the first work to reference Workbook_for_20131001.xls without going cell by cell and changing the name of the workbook. My thought was to make the date portion of the workbook name a variable and simply change that variable, but that doesn't seem to be working.
EDIT: I don't want to use Excel's INDIRECT function because I don't want to open the reference workbook.
I found one solution to be Harlan Grove’s PULL function (code can be found here), which works similarly to the INDIRECT function except that it doesn't require the source workbook to be open. The other solution, which actually works out to be faster than the Pull function (its only downfall) is the one I was using originally - Good ol' "find & replace". I thought that that was slow, but after trying the Pull function, it's not too bad.
Another option is by changing the source through excel's Data links, but this doesn't allow you to choose which cells keep the old source and which cells use the new one (in my case, I need the old values as well).