Clarification on what can be exported to excel on ipad - ipad

Trying to fix an old .asp site to work on an ipad. One of the features is the users ability to download their search results into an excel worksheet. The code uses:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=results.xls"
Response.CharSet = "iso-8859-1"
When viewing the site on the ipad, when the link is click for the page with the code above it does nothing, just spins. Is it the fact that I am trying to export the data as excel, I have read in some posts how it is the encoding! Should I convert the code to export the results page as a csv file and then allow the user to open it in anything they want/have available? What's the best way to do it to hit the most devices...
Thanks

In the past i'd a same scenario so what i did:
FILE: DOWNLOAD.ASP
<%
' get the file to download
myFile = request.querystring("File")
myFullPath = "c:\name_folder\" & myFile ' example of full path and filename
' set headers
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; filename=" & myFile
' send the file using the stream as
Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(myFullPath)
Response.BinaryWrite adoStream.Read()
adoStream.Close
Set adoStream = Nothing
%>
FILE: HTML
Download Excel file
This example is full working with Ipad using the native browser Safari.
The file Result.xls is downloaded and loaded in the Viewer whitout the capability to be edit.
My iPad users use the App QuickOffice to let the file be saved in a virtual folder, rename the file, delete, ... but they cant edit the file, that App is just for manage the files and isnt required for download the file.
If your user need also edit the XLS file on the iPad i suggest to use (for example) the Google App Document, it let the user to edit and manage the file directly in the browser.
Hope it help

Related

How to avoid Excel "bad format error" when saving spreadsheet

Using PHPSpreadsheet saving XLSX format works OK running the default code
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
$writer->save("filename.xlsx");
But if I want to have the user to select the target directory using
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="filename.xlsx"');
header('Cache-Control: max-age=0');
$writer = IOFactory::createWriter($spreadSheet, 'Xlsx');
$writer->save('php://output');
The file saves OK but Excel 2016 does not want to open it. Excel returns the following error
Excel Error
I looked through all documentation and posts but cannot find the solution.
Thanks !
Edit: Just in case, this solution does not work for me.
Edit 2: The sample provided Simple Download Xlsx works perfectly, but when doing a copy/paste for my spreadsheet, Chrome gives me a
Resource interpreted as Document but transferred with MIME type application/octet-stream
Edit 3: Used
ob_end_flush(); to clean any left over header in my code.
The file now saves OK, but needs repair when opening in Excel. Why ?
Thanks
Solution:
Bug from PhpSpreadsheet.
When using
header("Content-Type: application/vnd.ms-excel");
i.e. compatibility mode for Excel, the file opens OK.

TCPDF generated PDF to automatically display in Acrobat Reader

I am able to use TCPDF and generate a PDF in the browser using JQuery/JavaScript:
window.open("", "pdfWindow",scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
$("#" + formID).attr('action','tcpdf/example/genReport.pdf').attr('target','pdfWindow');
In genReport.pdf, I am using $pdf->Output('genReport.pdf', 'I');
When genReport.pdf is generated, it appears in a new tab with the standard browser settings. I wanted to know if there is a way to have the generated PDF automatically display in Acrobat Reader?
Any help will be greatly appreciated.
According to the documentation of the output() function, the second parameter can be one of those:
I: send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects
the "Save as" option on the link generating the PDF.
D: send to the browser and force a file download with the name given by name.
F: save to a local server file with the name given by name.
S: return the document as a string (name is ignored).
FI: equivalent to F + I option
FD: equivalent to F + D option
E: return the document as base64 mime multi-part email attachment (RFC 2045)
So I'd suggest using $pdf->Output('genReport.pdf', 'D'); this will open the download dialog and the user can choose to either open or download the file.

Linking a .doc file on a mvc view page

For something which seems so simple I can't find a solution, I have a word .doc file which I want to be linked on one of my pages so that a user can click on a link and open/download it (whichever is easier) and then read it on the machine with MS word.
Right now I have it in my content folder and tried to display it in both an and but no luck.
Is this an issue of IIS or just I'm going about this all wrong?
Present dir setup:-
Solution>Project>Content>File.doc
Solution>Project>Views>Home>NewRecord.cshtml
File location 1st followed by page I'm trying to display file on.
If I understand your problem correctly that you want to make User to Click and he/she will be promoted to download the .doc then.....
You can achieve with submit button which will be styled with CSS as LINK, then you perform the HTTP GET to the server within HTML form tag, Form will target the action on Server, which will return FileContentResult,
public FileContentResult GetWordDocument(string Id)
{
var contentDisposition = new ContentDisposition
{
FileName = "WordDoc.doc",
Inline = false;
};
FileContentResult documentResult= File(secureDoc.SecuredFileBytes,"application/msword", contentDisposition.FileName);
documentResult.ExecuteResult(this.ControllerContext);
return documentResult;
}
Content-Disposition:What are the differences between "inline" and "attachment"?
http://msdn.microsoft.com/en-us/library/system.web.mvc.filecontentresult(v=vs.108).aspx
Hope this will help to resolve.

Email a .txt file located in application storage directory Air iOS AS3

I would like to find out, how can I email a .txt file that is located in the application storage directory.
Thanks
Jared
Use applicationStorageDirectory and navigateToURL with mailto like so,
(Note: I am not going in depth with reading text file. I can help though if you need help. Putting it only to give some idea here.)
//Find the target file
var fileToFind:File = File.applicationStorageDirectory.resolvePath("filename.txt");
//Extract content from file
var fileStream:FileStream = new FileStream();
fileStream.openAsync(fileToFind, FileMode.READ);
//fileStream.addEventListener(Event.COMPLETE, showContent);
//fileStream.addEventListener(IOErrorEvent.IO_ERROR, alertError);
//To mail
navigateToURL(newURLRequest("mailto:someEmail#gmail.com"+"?subject=Subject"+"&body="+ textfileContents + "));
--
If you want to send attachment or HTML formatted email, see this link,
SMTPMailer
.
Best luck.

Using printer name Adobe PDF

I have looked everywhere for this solution. The code below allows me to print to the printer, Adobe PDF, but what I want to do is automate the file name save as screen with a generic name and in a specific folder. For example, the file would be saved to C:\temp\tmpResize.pdf and I am having problems there.
var params = this.getPrintParams();
params.interactive=params.constants.interactionLevel.silent;
params.pageHandling=params.constants.handling.none;
params.fileName = "/c/temp/tmpResize.pdf";
params.printerName="Adobe PDF"
this.print(params);
Thanks for your help.

Resources