JSP to Excel encoding problem. Value=? - excel

Jsp page shows arabic character verywell as like this:
about something bla bla تضارب توقعات شهر أكتوبر فيق الـ و الـ
but when I export it to Excel and try to open it,Excel says:
The file you are trying to open 'example.xls' is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?
After clicking yes, value is which I wrote before is:
about something bla bla ??????????????????????????
Jsp page has:
<%# page isELIgnored="false" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
if I copy arabic characters and paste it to Excel,Excel shows them clearly.
I use charset=cp1254.
when I change it to charset=cp1256, Value is like freak characters.
any ideas to fix it?

You're fooling Excel by a plain vanilla HTML file with the wrong extension. This is not going to work flawlessly, as Excel has warned you.
You need to serve a real binary XLS file using a Servlet, not some HTML table using a JSP. You can use Apache POI HSSF or JExcelAPI for this.

Related

How to open a HTML file in a non-default file type application(browser) using python?

Does anyone know how to open a HTML file in a browser that isn't the default HTML file type browser?
You can use below code
webbrowser.get("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s").open("file/path/name.html")

CUPS Linux: Help printing these media types: MS Excel, MS Word and HTML

I need to print MS Excel, MS Word and HTML files in a Linux CUPS server. When i try to print thses media types following occurs and this is what i've found till now:
For MS Excel and MS Word files:
When i try to print a file like these the error output is:
alvaro#alvaro-VM:~$ lp -d test_printer -o document-format=application/msword ptest.doc
lp: Unsupported format 'application/msword'!
or, the same:
alvaro#alvaro-VM:~$ lp -d test_printer ptest.doc
lp: Unsupported format 'application/msword'!
What i've found searching arround is that supposedly it is possible to use a CUPS filter, in this case the one i've found is called "officetop" (sourceforge/download link), taht would be possible to print MS OFFICE files. The problem i have with this "officetop" filter is that i don't know how to install it or counfigure it or whatever it needs to make it work and i couldn't find any tutorial or guide. So i wiil appreciate any help on this. Do you recommend use this filter to do this task? i'm open to any alternative solution.
For HTML files:
As a first test i made:
alvaro#alvaro-VM:~$ lp -d test_printer -o document-format=text/html index.html
the requested id is test_printer-105 (1 archivo(s))
And, which gave the same result:
alvaro#alvaro-VM:~$ lp -d test_printer index.html
the requested id is test_printer-106 (1 archivo(s))
index.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><body><h1>It works!</h1>
<p>This is a html print test.</p>
</body></html>
Result: on the printed sheet you can see just de html code instead the formated text.
EDIT: If i print a web page from the web browser like chrome it gets well printed but If i download the web page with the browser option "Save web page as" and then issue *lp -d test_printer index.html* occours the same i mentioned before, just the html code gets printed.
Please help on this. what I want is to get the formated text it is posible. It is also possible to print HTML+CSS?.
Thank you very much guys.
Regards.
PD: sorry about my english.
Remember Linux gets it's instructions on which applications to open which types of files from /etc/mailcap. Also, any type of file that is printed needs to be "rendered" or "compiled" by an application that is able to do so, hence the reference to /etc/mailcap. An e-mail application cannot "render" an Excel file, and Photoshop cannot open HTML files :) By the looks of it, you do not have an entry in your /etc/mailcap for an application to handle Excel, Word or HTML files, that is why the raw content is printed and not the "rendered" page (if you are printing from Linux). Are you printing from Linux or from Windows?. If you print from Windows (through the cups server on your Linux box) and it prints normal, then you know the problem is not the printer but /etc/mailcap on Linux.

How to export <table> content (which is inside a one <div >) into excel by JSP

I have developed a web application using JSP which creates a page with
several page elements and a with multiple records.
I wanted to export the content in that into an excel file.
I used the code
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename="
+ "excel.xls");
as described in this article http://www.quicklyjava.com/export-web-page-to-excel/
But it exports the whole page.
How can a export only the content in that particular table?
I cannot use the Apache POI library since i have to format(text colors,cell colors) the content in the JSP. And i need the same formatting in the excel file.
Can somebody help me with this? :)
Haven't found a way to export only a single table in a page.
But the intended task(create a excel sheet with formatted data) can be done by Apache POI HSSF library
Here are the links to learn how to & examples -
http://poi.apache.org/spreadsheet/how-to.html#user_api
http://poi.apache.org/spreadsheet/examples.html

VB/VBA: Fetch HTML string from clipboard (copied via web browser)

It seems that when you copy something from a web browser to the clipboard, at least 2 things are stored:
Plain text
HTML source code
Then it is up to the software that you are pasting into can determine which one it wants.
When pasting into MS Excel 2003, you have a paste special option to paste HTML, which will paste the formatted HTML (as it is displayed by the browser).
What I want to do is paste the actual source code as plain text. Can this be fetched from the clipboard in VBA?
Edit I'm trying to access all the source-code of the copied HTML, including the tags.
This time I've read the question properly and realised coonj wants to get the HTML from the clipboard including tags.
I believe this is reasonably difficult. You need to read the clipboard using Windows API calls. And then, parse the resulting CF_HTML string which has some wacky headers added on top of the HTML.
Microsoft Knowledge Base article with Windows API code to read the CF_HTML from the clipboard (function GetHTMLClipboard).
You will then probably want to ignore the wacky headers. Microsoft documents the format here. An example CF_HTML fragment is shown below. You could probably come up with some guesswork method of skipping the first few lines.
Version:0.9
StartHTML:71
EndHTML:170
StartFragment:140
EndFragment:160
StartSelection:140
EndSelection:160
<!DOCTYPE>
<HTML>
<HEAD>
<TITLE>The HTML Clipboard</TITLE>
<BASE HREF="http://sample/specs">
</HEAD>
<BODY>
<!--StartFragment --> <P>The Fragment</P>
<!--EndFragment -->
</BODY>
</HTML>
It might also be worth thinking whether there's any other way of solving your problem. E,g, Will the browser always be Internet Explorer? Can you get what you need by walking the HTML tree using the COM object model?
EDIT: coonj has tried this now and says "the GetHTMLClipboard function seems to work with both Firefox and IE, and it doesn't look like it is throwing those headers in there"
VB6 has the Clipboard object that allows you to get the clipboard data in different formats. VBA doesn't have this object. But there are windows API calls you can use. You can see a sample implementation for VBA here.

How to modify Sharepoint filetype icons depending on parts of the filename?

We have a SharePoint Document library, where we store html files with links to external files. Samples:
mypicture.jpg.html
mywordfile.docx.html
mypdffile.pdf.html
and so on. Now by default all Files show up with the HTML Icon, referenced in the DOCICON.XML file. Thats of course correct as the .html extension shows, it is a HTML file. But we want the files to have different icons, based on their original file type.
Is there a way to automatically change the Icon
during rendering or
when we save the file to the library (via SharePoint API)?
Any other approachs?
Why not use a little jquery to change the icon during rendering? Each doc in your library should be contained in
<td class="ms-vb-icon"><a tabindex=...><img ... src="/_layouts/images/ichtm.gif"></a></td>
I think you can slurp that into an array, assign a new var that's just the href stripped of path/filename. and .html, and use that to replace htm in the src tag.
Could you not just edit the DOCICON.xml to add the ".jpg.html" and ".docx.html" extensions in?
For a full listing of icon files see all "ic*.gif" files in the TEMPLATE\IMAGES directory under the 12 hive. Unfortunately, this will not solve your problem, but this is where you can change it based on the extension, if you so choose.
Note that a blog I wrote a while back has a different focus, but does discuss where the icons come from: http://wiki.threewill.com/display/is/2007/10/14/External+Link+for+Editing+a+SharePoint+Document.

Resources