Laravel Excel - File does not exist - excel

Laravel Excel 3.1
Laravel 8.75
PHP 7.4
Hello! I am using Laravel Excel package (https://github.com/SpartnerNL/Laravel-Excel) to export xlsx and csv files with text and images inside. I do from a view:
<table>
<thead>
<tr>
<th>Image</th>
<th>Name</th>
<th>SKU</th>
</tr>
</thead>
<tbody>
#foreach ($order->order_items as $item)
<tr>
<td><img src="{{ public_path('storage/' . $item->product->image) }}"</td>
<td>{{ $item->product->name }}</td>
<td>{{ $item->product->sku }}</td>
</tr>
#endforeach
</tbody>
</table>
In my local environment there is no problem but in production I get the following message:
File http://expo.zlestore.com/storage/products/rvhmSggWJquRpQvYLUMUvXEeUJzhlBx0xhDd4qal.jpg does not exist
I already run the storage link command and it is working. If I go to that link I see there is an image, the file actually exists but I can't export the file.. I tried different ways but without successs:
1) src="{{ Storage::url($item->product->image) }}">
2) src="{{ public_path('storage/' . $item->product->image) }}">
3) src='https://expo.zlestore.com/storage/' . $item->product->image>
4) src="{{asset('storage/'.$item->product->image)}}"
Could you help me with this?
Thank you in advance!
If I delete the img tag line everything works fine.
I expect the xlsx file to be exported correctly with images inside.

Solved. The correct way is
<img src="{{storage_path('app/public/'.$item->product->image)}}">

Related

Azure release pipeline got stuck to download the artifacts from build pipeline

May be this will some-one mark as duplicate, but please i have tried all the option to fix the issue but still I'm in same page.
Release Pipeline Logs
Below are option i have tried.
./cmd.sh using pem file configuration
./config.sh --sslcacert my.pem
Added environment variable using export command
export NODE_TLS_REJECT_UNAUTHORIZED=0
<title>The URL you requested has been blocked</title>
</head>
<body><div class="message-container">
<div class="logo"></div>
<h1>FortiGuard Intrusion Prevention - Access Blocked</h1>
<h3>Web Page Blocked</h3>
<p>The page you have requested has been blocked because the URL is banned.</p>
<table><tbody>
<tr>
<td>URL</td>
<td>https://myorg.visualstudio.com/</td>
</tr>
<tr>
<td>Description</td>
<td></td>
</tr>
<tr>
<td>Username</td>
<td></td>
</tr>
<tr>
<td>Group Name</td>
<td></td>
</tr>
<tr>
<td>URL Source</td>
<td>Local URLfilter Block</td>
</tr>
</tbody></table>
<p></p>
</div></body>
</html>

Selenium find iframe inside second tr that table as another tr that contains specific text

Not sure if the title is clear.
I have the following table:
<table>
<tbody>
<tr>
<td>
<div>Text to Find</div>
</td>
</tr>
<tr>
<td>
<iframe></iframe>
</td>
</tr>
</tbody>
</table>
and I have several of this blocks inside the application I am testing (this is simplified)
I want to get the iframe that is inside the "Text to Find" that this changes on each table that contains the iframe.
Is it possible? I have try something like this but isn't working:
//table[contains(.,'Text to Find')]/tbody/tr[2]/td/iframe
You are hard coding the row number in the x-path //table[contains(.,'Text to Find')]/tbody/tr[2]/td/iframe.
Your can try the following x-path.
//table/tbody/tr/td/div[contains(.,'Text to Find')]//iframe
You can try below xPath
//div[contains(Text(), 'Text to Find')]/../../following-sibling::tr/td/iframe
The problem was before this code. this is working as expected.
thank you for the replys

Create Excel file from existing rendered view in Symfony

I have a controller that renders up a template file (twig) with some forms and a table response.
I need to export to an Excel file that table response.
Is there a way to do that using Symfony, jQuery or Javascript?
I want to avoid using https://github.com/liuggio/ExcelBundle for which I need to recreate the objects.
I already have them created as they are used in twigs.
You can create an HTML table using Twig (using Twig is not necessary) and then save the output as an Excel file (.xls). You can use simple CSS in a <style> tag and in inline styles. For example:
<style>
.last {
color: red;
text-align: center;
}
</style>
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th style="font-style: italic">Country</th>
</tr>
</thead>
<tbody>
{% for row in data %}
<tr>
<td>row.name</td>
<td>row.age</td>
<td>row.country</td>
</tr>
{% endfor %}
<tr class="last">
<td colspan="3">This last row is red</td>
</tr>
</tbody>
</table>
When you open the file in Excel, you probably get a message saying:
The file you are trying to open file.xls is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?
There might be a workaround for this but I'm not sure.
This approach is simple and doesn't use any dependencies so it might be good enough for you if you don't need a very complex Excel file.
There are many resources with more information about this. See for example: How can I export tables to excel from a webpage.

Material Design Lite Lists - how to access selected elements?

I'm using Aurelia framework with Material Design Lite via plugin "aurelia-mdl-plugin".
I have the following markup:
<table class="mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--2dp">
<thead>
<tr>
<th class="mdl-data-table__cell--non-numeric">Name</th>
<th>Col2</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr repeat.for="s of items">
<td class="mdl-data-table__cell--non-numeric">${s.name}</td>
<td>${s.someothercol}</td>
<td>View</td>
</tr>
</tbody>
</table>
This markup represents a list of items that are selectable - each of them gets a checkbox with ability to select + the list gets "select all" check box in the header.
The problem is that since this additional markup with checkboxes is generated by MDL I can't really bind to it.
If I had a checkbox manually inserted I would do something like:
<input type="checkbox" checked.bind="s.IsChecked" />
Is there any way to fix this?
PS> I don't think it's necessarily Aurelia specific. Most likely I would have the same problem in Angular or other library..
The mdl team officially deprecated automatic checkbox insertion. So now you should write them down manually, which would solve your binding issue.
See this link: https://github.com/google/material-design-lite/wiki/Deprecations#automatic-selection-checkboxes

How to setup Smart search and result display for Custom table?

I have Custom table and Smart search index for it. Index type is Custom tables. Custom table has transformation for displaying table record.
What I need to do (Portal Engine development model) to:
Add search web part and what web part to use?
Display search results?
For now, I am using SmartSearchDialogWithResults. In Indexes I selected appropriate custom table search index and in Transformation name custom table transformation.
When I try to search - correct number of results and html formatting from transformation are present but no data.
Maybe this is not possible through Portal Engine development model?
There is transformation (transformation type: ASCX):
<table>
<tbody>
<tr class="border-top">
<td class="max-width-117">Name:</td>
<td><%# Eval("Name") %></td>
</tr>
<tr>
<td>Phone: </td>
<td><%#Eval("Phone")%></td>
</tr>
<tr>
<td>Email:</td>
<td>
<%#Eval("Email")%>
</td>
</tr>
</tbody>
</table>
This is render result:
<table>
<tbody>
<tr class="border-top">
<td class="max-width-117">Name:</td>
<td></td>
</tr>
<tr>
<td>Phone: </td>
<td></td>
</tr>
<tr>
<td>Email:</td>
<td>
</td>
</tr>
</tbody>
</table>
I fixed this problem after short searching and help from colleague.
The answer is simple: Yes, this is possible with Portal Engine development model. According to provided example: you need to use GetSearchValue instead of Eval in transformation.

Resources