In my Angular-12 project I installed file-saver:
npm install file-saver@2.0.5
npm install --save exceljs
ng generate service services/export-excel
Run Code Online (Sandbox Code Playgroud)
Then in the export-excel service, I added:
import * as fs from 'file-saver';
Run Code Online (Sandbox Code Playgroud)
I got file-saver highlighted
with this error:
Could not find a declaration file for module 'file-saver'. 'c:/xampp/htdocs/myapp/node_modules/file-saver/dist/FileSaver.min.js' implicitly has an 'any' type. Try
npm i --save-dev @types/file-saverif it exists or add a new declaration (.d.ts) file containingdeclare module 'file-saver';
But I didn't use:
@types/file-saver
How do I …
使用 Laravel-5.8 发送通知,我收到此错误:
\n\nFailed to authenticate on SMTP server with username "noblemfd@gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 23 \xe2\x96\xb6\n535 5.7.8 https://support.google.com/mail/?p=BadCredentials n13sm8684140wmd.21 - gsmtp\n". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535-5.7.8 \nUsername and Password not accepted. Learn more at\n535 5.7.8 https://support.google.com/mail/?p=BadCredentials n13sm8684140wmd.21 - gsmtp\n". Authenticator XOAUTH2 returned Expected response code 250 but got code "535", with message "535-5.7.8 \nUsername and Password not accepted. Learn more at\n535 5.7.8 …Run Code Online (Sandbox Code Playgroud) 在我的 Laravel 5.8 应用程序中,我有:
config/app.php
'date_format' => 'd/m/Y',
'date_format_js' => 'dd/mm/yy',
Run Code Online (Sandbox Code Playgroud)
模型
use Carbon\Carbon;
class HrHolidayDate extends Model
{
protected $table = 'hr_holiday_dates';
protected $fillable = [
'holiday_name',
'holiday_date',
];
protected $dates = [
'holiday_date'
];
protected $casts = [];
public function setHolidayDateAttribute($input)
{
$this->attributes['holiday_date'] =
Carbon::createFromFormat(config('app.date_format'), $input)->format('Y-m-d');
}
public function getHolidayDateAttribute($input)
{
return Carbon::createFromFormat('Y-m-d', $input)
->format(config('app.date_format'));
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试在 Blae 视图中对其进行格式化,如下所示:
view
@foreach($holidays as $key => $holiday)
<td>
{{Carbon\Carbon::parse($holiday->holiday_date)->format('d-m-Y') ?? '' }}
</td>
@endforeach
Run Code Online (Sandbox Code Playgroud)
当我想渲染视图刀片时,出现此错误:
[2020-07-15 11:57:56] production.ERROR: DateTime::__construct(): …
我正在尝试使用 Maatwebsites 将我的报告导出到我的 Laravel 5.8 项目中:
在 Laravel-5.8 中,我尝试使用 Maatwebsite 导出到 Excel:
<?php
namespace App\Exports;
use App\User;
use Carbon\Carbon;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\BeforeExport;
use Maatwebsite\Excel\Events\BeforeWriting;
use Maatwebsite\Excel\Events\BeforeSheet;
use Maatwebsite\Excel\Events\AfterSheet;
use Maatwebsite\Excel\Concerns\FromView;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithMapping;
use \Maatwebsite\Excel\Sheet;
use Maatwebsite\Excel\Concerns\RegistersEventListeners;
use Illuminate\Support\Facades\DB;
use Auth;
class EmployeesGoalPublishedExport implements FromCollection, ShouldAutoSize, WithHeadings
{
private $headings = [
'Staff ID',
'Name',
'Gender',
'Official Email',
'Department',
'HOD',
'HRBP',
'Line Manager',
'Goal …Run Code Online (Sandbox Code Playgroud) 我正在使用 Laravel-5.8 和 Maatwebsite-3.1 导出到 Excel。
<?php
namespace App\Exports;
use App\User;
use Auth;
class StudentExport implements FromCollection, ShouldAutoSize, WithHeadings, WithMappings, WithCustomStartCell
{
private $headings = [
'Student ID',
'Name',
'Class',
'Status',
'Teacher'
];
public function collection()
{
$current_terms = DB::table('appraisal_identity')->select('term_name')->where('company_id', $userCompany)->where('is_current', 1)->first()->term_name;
$publishedgoals = AppraisalGoal::select('employee_code')->where('is_published', 1)->where('company_id', $userCompany)->groupBy('employee_code')->get();
$published_goals = DB::table('hr_students AS e')
->join('hr_employees AS em','em.id','=','e.teacher_id')
->select(
'e.student_id',
DB::raw('CONCAT(e.first_name, " ", e.last_name) AS full_name'),
'e.student_class,
DB::raw('(CASE WHEN e.is_status = 3 THEN "Excellent" WHEN e.is_status = 2 THEN "Good" WHEN e.is_status = …Run Code Online (Sandbox Code Playgroud)