Excel Table + Images = Polished HTML Report

Hello!)

I need you to help me decide what is the best way to distribute daily technical reports.

I have a report in the excel format which contains of 5 sections with no images (each section is on a separate tab). Each section has 5 large charts assigned to it and which are stored separately.

I need to be able to present this information to my users online.

I have for now two options of doing this:

  1. export separate sheets of the excel report into separate HTML files – embed those into a single HTML file in Dreamweaver and include the external images so that everything is presented in a single large HTML page.

  2. Link separate sections of the report and the images to an indesign document so that all of these are placed on their own single page. Export the whole report as a PDF file.

I wish to present this report in a closed, password protected section of my website to a few of my clients. Which do you think of the above two ways is the best to present these reports?

I am concerned with the ease of sharing the PDF files online but of course someone can print a webpage to PDF if they like and do that as well.

I will be happy to hear any opinion!

Thanks!)

I would still love to hear what you think!)

I’m pretty lazy, so my first thought would be simply allowing your users to download the actual Excel document.

Are you worried that they might not all have Excel/the right version of Excel?

If your document transfers well enough to Google Docs, then you’d be okay. (I imagine.)

I’d choose – NONE OF THE ABOVE! :smiley:

I’d export them as CSV, then read that into PHP to generate the appropriate HTML… and then maybe use PHP’s GD module, HTML elements or even Canvas to draw the charts. (though Canvas would fail IE8-… there is a shiv to turn it into VML for legacy IE, I’ve had bad results with it). I’d have to see an example of the charts to weigh in more on it.

This approach would probably be the simplest in the long run, as when you update all you’d have to do is export new CSV’s and point the PHP at it.

Yes…I woudl not wish to share the original excel files…besides I would not want the people to think that the analysis was originally made in excel…ideally a html version that does nto look liek exported excel would suit this purpose the best)))) besides I want to distribute these reports on the closed password-protected part of my website…

very interesting…as someone who has no pho experience - can you please point me to an example on how this can be done? maybe a tutorial or somethign like that?

I thought of exporting individual tables in excel report as the standalone html pages and then assembling them in the dreamweaver - do you think this can work?

my aim is to have a bullt-proof method of delivering reports via web which I can maintain on my own without the need to consult with the programmers…

Can’t think of any tutorials off-hand, but I can give you a quick run-down of how to do that. The key PHP function you need is called ‘fgetcsv’ – because like most C syntax language functions, there’s this paranoid hatred of descriptive names as if two or three characters is going to kill us. “fileGetCSV” would be much more clear, and is what it does. (I swear some programmers WANT programming to be hard, see “google rust”)

Let’s say you had a simple 3 column table of a home budget, saved as CSV:

budget.csv


"Action","Amount","Total"
"Income Feb 2011",2066,2066
"Rent",-1200,866
"Electric",-140,726
"Cable/Internet",-122.60,603.40
"Groceries",-400,203.40
"","",""
"Income March 2011",2066,2269.40
"Rent",-1200,1069.40
"Electric",-140,929.40
"Cable/Internet",-122.60,806.80
"Groceries",-400,$606.80

the first row is the labels for the columns, each line there-after containing our comma separated cells.

First thing you’d need to do in your PHP is open the file…


if ($handle=fopen($fileName,'r')) {

The ‘fopen’ command opens the file (again with the cryptic abbreviations), and returns a handle (id code) to access the file with. the ‘r’ means to open the file as read-only. Then you just need to process all the rows:


$row=fgetcsv($handle,0x400)

Which plugs a ‘row’ of cells into our $row variable. The 0x400 (hexadecimal) is the same as 1024 – basically it says to not allow lines longer than 1k. (which saves memory and runs faster)

This is typically done inside a ‘while’ command so it continues until end of file.


while ($row=fgetcsv($handle,0x400)) {

… which you can then echo out:


echo '
  <tr>
    <th scope="row">',$row[0],'</th>
    <td>',$row[1],'</td>
    <td>',$row[2],'</td>
  </tr>';

That’s the basics of it. A more robust handler would auto-figure out how many rows there are, put the first row in a THEAD as all TH, auto-detect the first row on the TBODY values, build a colgroup for CSS off formatting… use a define for the max CSV line length and a variable for the filename… pretty much this would be a ‘better’ version of the above:


<?php

define(MAX_CSV_ROW,0x400);
$fileName='budget.csv';

if (
	($handle=fopen($fileName,'r')) &&
	($row=fgetcsv($handle,MAX_CSV_ROW))
) {

	echo '
		<table>
		
			<caption>',$fileName,'</caption>
			
			<colgroup>';
		
	$columns=count($row);
	for ($counter=0; $counter<$columns; $counter++) {
		echo '
				<col align="',(
					$counter==0 ? 'left' : 'right'
				),'" />';
	}
	
	echo '
			</colgroup>
	
			<thead>
				<tr>';
			
	foreach ($row as $data) {
		echo '
					<th scope="col">',$data,'</th>';
	}
	
	echo '
				</tr>
			</thead>
			
			<tbody>
				';
			
	while ($row=fgetcsv($handle,MAX_CSV_ROW)) {
	
		echo '<tr>';
				
		$count=0;
		foreach ($row as $data) {
			$tag=($count++==0 ? 'th' : 'td');
			echo '
					<',$tag,(
						$tag=='th' ? ' scope="row"' : ''
					),'>',(
						is_numeric($data) ? number_format($data,2) : $data
					),'</',$tag,'>';
		}
		echo '
				</tr>';
	}
	
	echo '
			</tbody>
			
		</table>';
		
	fclose($handle);
	
} else {

	echo '
		<p>
			There was an error opening "budget.csv"
		</p>';
		
}
?>

Which using the above budget.csv would output a nice semantic proper table with all the proper relationships/scope declared:



		<table>
		
			<caption>budget.csv</caption>
			
			<colgroup>
				<col align="left" />
				<col align="right" />
				<col align="right" />
			</colgroup>
	
			<thead>
				<tr>
					<th scope="col">Action</th>
					<th scope="col">Amount</th>
					<th scope="col">Total</th>
				</tr>
			</thead>
			
			<tbody>
				<tr>
					<th scope="row">Income Feb 2011</th>
					<td>2,066.00</td>
					<td>2,066.00</td>
				</tr><tr>
					<th scope="row">Rent</th>
					<td>-1,200.00</td>
					<td>866.00</td>
				</tr><tr>
					<th scope="row">Electric</th>
					<td>-140.00</td>
					<td>726.00</td>
				</tr><tr>
					<th scope="row">Cable/Internet</th>
					<td>-122.60</td>
					<td>603.40</td>
				</tr><tr>
					<th scope="row">Groceries</th>
					<td>-400.00</td>
					<td>203.40</td>
				</tr><tr>
					<th scope="row"></th>
					<td></td>
					<td></td>
				</tr><tr>
					<th scope="row">Income March 2011</th>
					<td>2,066.00</td>
					<td>2,269.40</td>
				</tr><tr>
					<th scope="row">Rent</th>
					<td>-1,200.00</td>
					<td>1,069.40</td>
				</tr><tr>
					<th scope="row">Electric</th>
					<td>-140.00</td>
					<td>929.40</td>
				</tr><tr>
					<th scope="row">Cable/Internet</th>
					<td>-122.60</td>
					<td>806.80</td>
				</tr><tr>
					<th scope="row">Groceries</th>
					<td>-400.00</td>
					<td>$606.80</td>
				</tr>
			</tbody>
			
		</table>

Will need some CSS to be really pretty – still annoys me that Firefox/gecko based browsers STILL don’t support align on the COL tags – See Bugzilla 915… ALSO annoying not one browser out there supports align=“char” – a value that when working with tabular data (like a table) should be considered essential and has been in the specification since 1998. LOVE all this idiocy of adding new stuff to browsers when they don’t even have the old stuff working right yet.

Given that the HTML output from ANY of the office software is totally USELESS bloated rubbish I’d NEVER put on a website, and then Dreamweaver is a fat bloated steaming pile that, well… as a dearly departed friend often said “the only thing you can learn from Dreamweaver is how NOT to build a website” – Uhm… NO!!!

Methinks the two are mutually exclusive – though once you have the code to handle it written and if you can keep your spreadsheet formats consistent with no extraneous data, it should be a WOUM. (Write once, Use Mostly).

thank you for this generous help!) I will be testing this code in a few moments!))) I had a short question…You knwo what previously discouraged me from exporting raw excel data is that this will lose the incell formatting obviously…I have a table which colours cells which are below -0.5 in red and in gree those which are above +0.5 and yellow all inbetween - I wonder if this type of formatting can be made in dremaweaver or php?

I also have another formatting need - I need to colour-code a few cells in the table based on the first character in them - for eaxmple if the cell behins with H: it shoudl be coloured in yellow and if it begins with T: it shoudl be coloured in red…hopefully that is possible…
thanks!)

While I love DS60’s solution, the truth is that I would first consider the advantages and disadvantages of having the information online as a html page or as a regular (pdf) file or both.

Depending on my reasons to do this, who’s reading it and my own goals, I may choose PDF, HTML or both.

Since I don’t have enough information, I’d go for PDF. :slight_smile:

Only if there’s certain attribute or class that can differenciate one cell from the next.

you could add a few lines in your PHP code to add the classes automatically as the cells are built and then use CSS to give it color.

Well, I need to create a member only section of a website which will feature reports for 50 different companies…there will be summary reports of the various metrics used for each company…each company report will have multiple tables and on average 20 different images…packing it all in one pdf could mean it will weight around 100 mbs or more…so I am thinking of the web interface to access the reports…this makes sense to you?

In light of all that huge amount of the reports to be shown online I think that using a coding solution to this could be problematic—given the fat that I want to updates the reports on the DAILY basis…you still think it would be better to go with the pdf? Pdfs are great for combing tables and images in one coherent way but they can be huge and I would not want the daily reports to be easily shared.

A report with 20 images and multiple tables doesn’t need to weight 100 MB. That would be huge tables and extremely high quality photographs (not graphics, they would for sure weight less than that). 1-2 MB would be more like it. Maybe even 10 MB but 100 MB?

Think that a PDF book with 500-800 pages and all its graphics and pictures is about 10-20 MB

It is nice to give the users the ability to choose. I guess that I would go for a online version with a link to print that report (either by regular printer or in PDF form). PHP can create the PDF on-the-fly.

So you mean that you will use DS60’s script to export and create a neat table and get a static HTML file… am I understanding correctly?

Thank you for your kind reply…yes but my images are high resolution charts - each of about 200 kbs or more there are around 700 of them for the whole report so this can total up for a large pdf file…right now I am thinkign how to automate the whole procedure…php connections can work fine with multiple files at the same time? and there is also the INTERCONNECTION among the reports that I need to think of…you think a daily report of 130 mbs PDF file woudl be fine?

Have you ever used Google Analytics? or any service that provided charts on a web? do you truly believe that the graphic was already done, and saved as a picture?

No, they’re done on the fly. Data is kept on a database, and with some kind of programming language the chart is created instantly. Which is what Excel does, by the way.

An even if you save 700 of them, charts are vector graphics, that is, formulas. If you save them as jpg then they will stop being vectors… but the PDF format recudes sizes so much because it treats as a vector what is supposed to be a vector.

And if it is saved as a vector, it will never lose quality, no matter if you reduce its size… because it is a formula that the computer redraws.

I assume that if you think the report weights 100 Mbs is because you’ve already saved it as PDF… but this would be the very first time that I find a PDF with such a weight! If it would be fine or not will depend on the importance of that data for your customers and their bandwidth.

Regarding the interconnection among reports, that depends on how you work with data. If you manage to create the right work flow, there shouldn’t be much of a problem. But I can’t tell. I don’t really know what you want to do, what kind of information it is and how it relates to each other.

Still, if the amount of information is so huge, maybe you should be considering the database route because databases were created to keep data and relational databases where constructed to keep data that it is related to other data

Thank you very much for your thoughtful and deep response…that is very helpful to read…the thing is the images are generated by another charting application and there are quite a few different measures on the charts which makes it necessary for them to be high resolution charts - like 5000 pixels by 7000 pixels…I want the clients to see all measures when they zoom on the charts - they are in the PNG format…smaller images just lose the metrics…I have zero experience working with the databases…I would hire a full-time programmer once the I have a few subscribers (I would need a full time help in anything apart from excel and simple htlm:eek:)…but for now that is not possible…I am concerned with the quality of the html generated by excel…I can still preserve the original look of the excel sheet - right? there are nice excel dashboards which show that excel can be made to output nice lookign analysis (ex http://www.excelcharts.com/blog/how-to-create-an-excel-dashboard/)…but is the html cose of excel generated webpage just too bulky ? do you think this can be a difficulty for showing analysis to a selected group of the customers?
thanks again for your time and interest!)

@dima777; if you’re using an external application to do the charts whcih then are saved as pictures (png format in this case) that doesn’t mean that you have to keep it like that.

5000 x 7000px is huge in size (that doesn’t mean that they’re high resolution. You can reduce the size once the png file has been created and see if it works. That doesn’t necessarily mean that it will change the cm or in that image would need if it is printed, this is question of screen size (we’re talking about px). That would lower the size. Some graphic software (like Photoshop) have batch processes like this one. You put all the images in one folder, tell the program what to do (in this case, changing the number of px proportionally) and the program itself will go picture by picture, resizing every single one of them automatically.

The second question is… do all of your subscribers need such amount of information? Or would they rather receive the charts of one or two companies? That could be another solution.

Definitely, the page generated by excel would be to bulky although if that’s the best you can do, that’s the best that you will be able to do (for the moment)

And your link doesn’t work :slight_smile:

thank you for your kind reply)) well not all of my clients would have access to 50 companies reports…for trading purposes it is necessary to have as may companies at your fingertips as possibel so as to diversify the portfolio effectively)…I will surely try to resize the pictures in the photoshop…in the meanwhile I was abel to test a nice software called All Office Converter which can convert - rather batch convert a lot of the excel files and create clean html code for each of the tabs of the files…I now need to find a way to aggregate the resultant separate tables in the exported html format on one page - can you please suggest what woudl be the most effective way to do that??? is there a way to have a html page have embedded html parts from other html pages? which can be embeded itno it?or they can only be referenced by IFRAME command? thank you very much for your generous help! )

as for that like here it is:

maybe someone can recommend some more excel to html converters? as the All Office Converter does not preserve the formatting of the original excel sheet…thanks!!)

Simply get rid of the <head> </header> elements and everything in between in all html files except the one where everything should go. Also remove the html and body tags. Leave the rest.

Then, in the page where you wanta to include everything, go to the bottom and right before the body tag closes, add an include instruction to add the file

<!--#include virtual="nameOfFile.html" -->

or

<!--#include file="nameOfFile.html" -->

If you use include virtual, it means that the path to the html file is in relation to the current document. If you use virtual, the path is given in relation to the root of the current document.