oasisp
Posts: 48
|
| Posted: 07/28/2010, 12:39 PM |
|
Newbie to CCS finally figure out how to Export to EXCEL it was tough. but its exporing whole html in xls format. only wanted report to export to excel not all html. any help would really appreciate. on xls file i see all html code. did missed any steps? i went though example http://examples.codecharge.com/ExamplePack/ExportToExce...oExcel_desc.php
|
 |
 |
JimmyCrackedCorn
Posts: 583
|
| Posted: 07/28/2010, 1:54 PM |
|
I think that is the only way CCS exports to Excel. I am not aware of an option to export to native Excel format. Why won't this work for you?
_________________
Walter Kempees...you are dearly missed. |
 |
 |
oasisp
Posts: 48
|
| Posted: 07/28/2010, 1:58 PM |
|
it is exporting to excel but its includes all the html as well in xls.
|
 |
 |
ckroon
Posts: 869
|
| Posted: 07/30/2010, 2:33 PM |
|
Yo!
Took me forever to figure this out so I share it with you...
Make your grid with the data you want on it and remove all style sheets, security and references to Style Sheets.
Paste this in the head of the page (HTML tab)
Quote :<meta content="Excel.Sheet" name="ProgId">
<meta content="Microsoft Excel 11" name="Generator">
<style> <!--table @page{} -->
</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
<x:Name>CSUTOMIZENAMEHERE</x:Name>
<x:WorksheetOptions><x:Panes>
</x:Panes></x:WorksheetOptions>
</x:ExcelWorksheet></x:ExcelWorksheets></ x:ExcelWorkbook>
</xml> <![endif]-->
NOW... make a Before Show event for the Page.
And paste this bad boy...
Quote :$header = "Header1" . "\t";
$header .= "Header2" . "\t";
//Reading the data thro' POST
$data= $_POST['header1']. "\t";
$data .= $_POST['header2'] . "\t";
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=YOURREPORTNAMEHERE.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
Voila!
Only glitch is that the xls shows up without grid lines... In excel.. the user just has to go to Tools->View and check the box next to grid lines.
Enjoy!
_________________
Walter Kempees...you are dearly missed. |
 |
 |
Waspman
Posts: 948
|
| Posted: 08/01/2010, 11:59 AM |
|
I've done it like this forever...
Header("Content-type: application/vnd.ms-excel");
Header("Content-Disposition: inline; filename=\"Filename.xls\"");
Remove all style refs in html and stick the above code in before show.
It does keep the cell outline and any text formatting such as colour.
_________________
http://www.waspmedia.co.uk |
 |
 |
ckroon
Posts: 869
|
| Posted: 08/01/2010, 3:46 PM |
|
But.. my way is sooo much more complicated! 
Thanks Waspman!
_________________
Walter Kempees...you are dearly missed. |
 |
 |
Waspman
Posts: 948
|
| Posted: 08/02/2010, 8:14 AM |
|
_________________
http://www.waspmedia.co.uk |
 |
 |
oasisp
Posts: 48
|
| Posted: 08/02/2010, 10:53 AM |
|
so i cant have any css style refs in html ? when i doing export to excel??
|
 |
 |
oasisp
Posts: 48
|
| Posted: 08/02/2010, 11:03 AM |
|
i also have header & footer page included. it shows up on excel when i click on exprt to excel as well.
|
 |
 |
oasisp
Posts: 48
|
| Posted: 08/02/2010, 11:33 AM |
|
when i try to open excel sheet get following error. in excel.
Problems came up in the following areas during load:
Misssing files : c:\styles\pine\style_doctype.css
ofcource it going to be missing. is there a way to hide css when exporting?
|
 |
 |
laneoc
Posts: 154
|
| Posted: 08/02/2010, 5:26 PM |
|
You'll need some BeforeShow (page) code to eliminate the footers, headers, and errors referring to style sheets. Something along the lines of this should work:
$Attributes->SetValue("StyleAttr", '<link rel="stylesheet" type="text/css" href="Styles/yourStyleSheet/Style_doctype.css">');
if (CCGetFromGet("export") == "1")
{ $Attributes->SetValue("StyleAttr", "");
$yourHeaderThing->Visible=false;
$yourFooterThing->Visible=false;
}
In the HTML, there is the following code just after the meta GENERATOR line:
{page:StyleAttr2}
Whenever this page is visited with a URL parameter of "export=1", the stylesheet spec will be blanked out and the "...Things" will be invisible.
Also -- you can incorporate HTML style stuff like <font face='Helvetica'> and <strong> if you are so inclined. Excel will process these tags *mostly* as expected.
_________________
Lane |
 |
 |
Waspman
Posts: 948
|
| Posted: 08/03/2010, 2:59 AM |
|
So you're not exporting a special clean page to Excel?
_________________
http://www.waspmedia.co.uk |
 |
 |
ckroon
Posts: 869
|
| Posted: 08/03/2010, 12:22 PM |
|
Waspman... any idea why when I export to excel with your code I dont get grid lines?
Do i need to have the grid lines on my clean page?
_________________
Walter Kempees...you are dearly missed. |
 |
 |
oasisp
Posts: 48
|
| Posted: 08/05/2010, 11:21 AM |
|
laneoc, thanks that fixed .
Waspman yes i am not exporting clean page i using css, html header footer for design
thanks all
|
 |
 |
Waspman
Posts: 948
|
| Posted: 08/06/2010, 1:05 AM |
|
Quote ckroon:
Waspman... any idea why when I export to excel with your code I dont get grid lines?
Do i need to have the grid lines on my clean page?
Ya have to add the table border
_________________
http://www.waspmedia.co.uk |
 |
 |
pondix
Posts: 5
|
| Posted: 09/20/2010, 11:59 AM |
|
Quote ckroon:
Yo!
Took me forever to figure this out so I share it with you...
Make your grid with the data you want on it and remove all style sheets, security and references to Style Sheets.
Paste this in the head of the page (HTML tab)
Quote :<meta content="Excel.Sheet" name="ProgId">
<meta content="Microsoft Excel 11" name="Generator">
<style> <!--table @page{} -->
</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
<x:Name>CSUTOMIZENAMEHERE</x:Name>
<x:WorksheetOptions><x:Panes>
</x:Panes></x:WorksheetOptions>
</x:ExcelWorksheet></x:ExcelWorksheets></ x:ExcelWorkbook>
</xml> <![endif]-->
NOW... make a Before Show event for the Page.
And paste this bad boy...
Quote :$header = "Header1" . "\t";
$header .= "Header2" . "\t";
//Reading the data thro' POST
$data= $_POST['header1']. "\t";
$data .= $_POST['header2'] . "\t";
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=YOURREPORTNAMEHERE.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
Voila!
Only glitch is that the xls shows up without grid lines... In excel.. the user just has to go to Tools->View and check the box next to grid lines.
Enjoy!
i did all that but wen ever i go to the live page,it takes me direct to excel without clicking on export to excel link.what do i do now????
_________________
Zambian Programmer in the making |
 |
 |
ckroon
Posts: 869
|
| Posted: 09/20/2010, 12:26 PM |
|
You need to link TO that page.
I usually present the user with a grid showing the same data.. with an Export to Excel link somewhere on that page.. and link to that report page.
_________________
Walter Kempees...you are dearly missed. |
 |
 |
pondix
Posts: 5
|
| Posted: 09/20/2010, 12:29 PM |
|
explain more on that please
_________________
Zambian Programmer in the making |
 |
 |
pondix
Posts: 5
|
| Posted: 09/20/2010, 12:31 PM |
|
Quote ckroon:
You need to link TO that page.
I usually present the user with a grid showing the same data.. with an Export to Excel link somewhere on that page.. and link to that report page.
please explain more on that one
_________________
Zambian Programmer in the making |
 |
 |
ckroon
Posts: 869
|
| Posted: 09/20/2010, 8:06 PM |
|
Not sure what else I can say... :)
The page you made, that opens in excel when you run it.. that is the REPORT.
So.. just link to that page...
_________________
Walter Kempees...you are dearly missed. |
 |
 |