Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:14:13+00:00 2026-06-13T12:14:13+00:00

I met some troubles while using PHPExcel, In fact I have read all the

  • 0

I met some troubles while using PHPExcel,

In fact I have read all the tutorials I’ve found but it does not work for me.

I’ve put this code on the page:

$i = -1; // index des enregistrements

$objPHPExcel->setActiveSheetIndex(0);
$sheet->getColumnDimension('A')->setWidth(75);
$sheet->getColumnDimension('B')->setWidth(150);
$sheet->getColumnDimension('C')->setWidth(190);
$sheet->getColumnDimension('D')->setWidth(150);
$sheet->getColumnDimension('E')->setWidth(115);
$sheet->getColumnDimension('F')->setWidth(115);
$sheet->getColumnDimension('G')->setWidth(380);
$sheet->getColumnDimension('H')->setWidth(75);
$objPHPExcel->getActiveSheet()->SetCellValue('D1', '<img src="images/agenda.png" alt="AGENDA" width="168" height="24">');
$objPHPExcel->getActiveSheet()->SetCellValue('A3', 'Du '.$_REQUEST['date1'].' Au '.$_REQUEST['date2'].', Critères: '.$_REQUEST['tache'] );
$objPHPExcel->getActiveSheet()->SetCellValue('A5', 'CLIENT');
$objPHPExcel->getActiveSheet()->SetCellValue('B5', 'N° DE DOSSIER');
$objPHPExcel->getActiveSheet()->SetCellValue('C5', 'DEBITEUR');
$objPHPExcel->getActiveSheet()->SetCellValue('D5', 'TEL');
$objPHPExcel->getActiveSheet()->SetCellValue('E5', 'DATE');
$objPHPExcel->getActiveSheet()->SetCellValue('F5', 'TRAITEMENT');
$objPHPExcel->getActiveSheet()->SetCellValue('G5', 'DESCRIPTION');
$objPHPExcel->getActiveSheet()->SetCellValue('H5', 'RESTANT DU EN PPAL');

But it give to me the following errors:

Notice: Undefined variable: sheet in Line 173

Notice: Undefined variable: sheet in Line 173

I’m really Lost, I thought it wad that way for changing column sizes.

Any kind of help will be much appreciated.

Kind Regards.

SP.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:14:14+00:00Added an answer on June 13, 2026 at 12:14 pm

    You must define $sheet before using it, like any variable in PHP it doesn’t exist until it’s actually created; but you also want it to be the actual PHPExcel worksheet where you want to set the column widths.

    So

    instead of

    $objPHPExcel->setActiveSheetIndex(0);
    

    use

    $sheet = $objPHPExcel->setActiveSheetIndex(0);
    

    which works because a call to the setActiveSheetIndex() returns the active worksheet object

    Once $sheet has been defined as the current Worksheet, you can make your calls to set the column widths

    EDIT

    Then you can also simplify your calls to set cell values from

    $objPHPExcel->getActiveSheet()->SetCellValue('D1', '<img src="images/agenda.png" alt="AGENDA" width="168" height="24">
    

    to

    $sheet->SetCellValue('D1', '<img src="images/agenda.png" alt="AGENDA" width="168" height="24">
    

    etc

    Note however that setting HTML markup in a cell is simply setting cell to contain a text string, this will not embed an image in your worksheet

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I met some problems while using GDI+ for drawing different images in my program.
I met some compilation error but do not know what the problem is. The
I have some design requirements that are not supported by Entity Framework, but are
I met some trouble while using input type dates, also I decided for reasons
I have an implementation that just like gmail application, but have met some problem
I have some MET data I want to validate which would look something like
I have some logic in before_save whereby (only) when some conditions are met I
I have already installed jboss server on my mac, however, i met some problems
I met some basic problem in jquery, but I can't figure it out. Here
I'm trying to call a JavaScript function through PHP and have met some problems.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.