Export MYSQL phpadmin to Excel - php

I am a little new to MYSQL and PHP so any help is much appreciated. I have a database right now that is storing ten values, a name and 9 scores. I also have an excel spreadsheet that has the names and empty slots for those 9 scores. I have a bunch of formulas that use those 9 scores to calculate other scores. Is it possible to read those 9 scores for each individual name from my database then place them into that specific slot of the spread sheet based on there name? I do not want to write to a new spread sheet but rather input these scores into that spreadsheet that is being used. Thanks in advance!

In PhpMyAdmin select your database, then export -> CSV or CSV for MS Excel
Take a look at the screenshot:

Related

PHP Spreadsheet get rows number starting from a specific cell position

Hello i need to get the number of recorded rows of an excel
im using this method to count rows but it gets all rows
$worksheet->getHighestRow()
I didn't find in the docs how to start counting from A9 for example
Any suggestions?
Thanks for help

How to set excel cell as read-only using Laravel - Maatwebsite?

I want to download a report with sum of two columns to be displayed in another column. I want to make the answer cells to be read-only i.e., non-editable. How to make it using Laravel-Maatwebsite?
I have performed the sum formula.
$sheet->cell('C1', function($cell){
$cell->setValue("=SUM('A1:B1')");
});
I looked for protect cell function but I couldn't find.
I found one solution how you can use protected cell function
$sheet->protectCells('A1:F1', 'PASSWORD');
$sheet->getStyle('A2:F50')->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED);
// here in the place of F50 you can pass maximum range like F2000
$sheet->getDelegate()->getProtection()->setSheet(true);
Though the question was asked like 3 years ago but this might help someone in future !

PHPExcel : How to get the cell text and not the formal without calculating the formals during runtime

I have an Excel file with 2 worksheets.
1st sheet has almost 5000 rows which are of no use to me.
2nd sheet has 25 rows which are only the required rows, But these rows are obtained from formulas in referring to 1st sheet.
Now the problem is that i am loading only the 2nd sheet using PHPexcel setLoadSheetsOnly() for better performance. Hence system is not able to calculate the formulas which are referring the 1st sheet.
My Requirement is that i want the read the cell text only (Content Displayed in cell and not the formulas).
i have used getFormattedValue() and getCalculatedValue() but it doesn't help.
Is there any function or any way by which i can read just the cell text irrespective any formula and without loading the 1st sheet.
will appreciate any inputs/thoughts/recommendations ..
Thanks in advance.
You should use the getCalculatedValue() method: if that doesn't work, then what does it return?
But if the formula is dependent on data in another sheet, then you need that other sheet loaded else how can the calculation be done.
The other option is the getOldCalculatedValue() method; but that isn't guaranteed.
EDIT
/**
* Get old calculated value (cached)
* This returns the value last calculated by MS Excel or whichever spreadsheet
* program was used to create the original spreadsheet file.
* Note that this value is not guaranteed to refelect the actual calculated value
* because it is possible that auto-calculation was disabled in the original
* spreadsheet, and underlying data values used by the formula have changed
* since it was last calculated.
*/

Mysql query to show results from between two columns

Hi i have a mysql database, in which i have two columns Year_from & Year_two.
what i am trying to do is find a way where i can show the dates that are missing as buttons, for example if year from is 2006 and year to is 2008, i of course want to show 2006, 2007 and 2008. is this possible, as there isn't the value of 2007 in the database.
I haven't worked on any code yet as i am not sure if this is possible, or how i would achieve it.
Any ideas would be appreciated.
Thanks
Use range($year_from, $year_to) to generate a list of all years. Compare that array with the one you got from the database using array_diff() and bold the missing ones.
This needs to be done in code.
Basically, you'll read a bunch of records from the database, iterate through an array of years you'd like to show and check (every iteration) if there is a matching record present in the result set.

php process - one after another - simulating threading

I have a report generation functionality.
Export to csv or txt .
For each month it will be 25000 records each row with 55 columns.
For yearly it will be more than 300000!!
i try to add memory limit ,but i dont think its good!! Anyway now its 128M.
My expectation
I will split the date range selected by user into a range of 25 days or 30.
I will run fetch data for 25 days , then write the csv.
Then fetch next 25000 , write that . like this.
How can I attain this?
for fetching am using a function $result= fetchRecords();
For writing csv , I am passing this $result array to view page and by looping and seperating by comma am printing.
So in controller it will be $template->records=$result;
If i do this in a for loop
for(){
$result= fetchRecords();
$template->records=$result;
}
I dont hink this will work.
How to do this? execute fetch.write then fetch then write.
Can you please suggest better way to implement this in PHP keeping it in memory limt?
I was fetching a huge data from db to an array . Then again loop this array to write into csv or text.That was really killing the memory.
Now , as i am fetching data from db , in that same loop am writing to the file.
No usage of array. Great difference.
PHP can do better export to csv or text. PHP is really a great language.
Now am downloading a csv of 25 mb . :) i break the excel.. as it exceed 65550 records .:)
More than enough for me.
So the lesson learned is- Dont use arrays for this type of huge data storing.

Categories