Code Monkey home page Code Monkey logo

Comments (6)

sbraconnier avatar sbraconnier commented on May 12, 2024

@evserykh Sure I am. I'm about to release the next version of JODConverter. It should be out within a week.

Not sure I understand your question. But everything you can do using OO only (without JODConverter) is doable with JODConverter. We just have to figure out how to do it programmatically.

What are you tryinh to do exactly ? (what is you input and output format?).

from jodconverter.

evserykh avatar evserykh commented on May 12, 2024

Sounds great, it would be amazing 👍

Let me explain what I mean. For example I have a csv file in cp1251 encoding and I want to convert it to a xls file. Using OO I have to open the csv file and select file's encoding to have it properly showed. Do you know is it possible to set input file's encoding for converting requests to jodconverter?

from jodconverter.

sbraconnier avatar sbraconnier commented on May 12, 2024

OK got it.

First, take a look at this wiki page to understand what I'm about to explain.

The default filter options applied when a csv file is imported is 44,34,0, which means comma as field separator, " as text delimiter and system encoding as file encoding.

What you want, according to this table, is 44,34,34.

You can change these default options by forcing a custom format as source format:

Using the latest master:

File inputFile = new File("document.csv");
File outputFile = new File("document.xls");

DocumentFormat csv = DocumentFormat.copy(DefaultDocumentFormatRegistry.CSV);
csv.getLoadProperties().put("FilterOptions", "44,34,34");

JodConverter.convert(inputFile).as(csv).to(outputFile).execute();

Using the 4.0.0 version:

OfficeDocumentConverter converter = ...

File inputFile = new File("document.csv");
File outputFile = new File("document.xls");

final DocumentFormatRegistry registry = DefaultDocumentFormatRegistry.create();
DocumentFormat inputFormat = registry.getFormatByExtension("csv");
DocumentFormat outputFormat = registry.getFormatByExtension("xls");

inputFormat.getLoadProperties().put("FilterOptions", "44,34,34");
converter.convert(inputFile, outputFile, inputFormat, outputFormat);

Note that I didn't test this but it should work as expected...

from jodconverter.

evserykh avatar evserykh commented on May 12, 2024

@sbraconnier thanks a lot. I got what you meant, but I use jodconverter web app. I asked whether can I modify my requests to jodconverter web app to set input file's encoding.

from jodconverter.

sbraconnier avatar sbraconnier commented on May 12, 2024

Hmm...

Do you mean you use the jodconverter-sample-webapp sample ?

If yes, my answer remains the same. The sample webapp is... well, just a sample. It is not too hard to send request parameters through a web request. You could add a drop down list of available encoding and send the selected option to the server using a request parameter (see query string). Server side, you would retrieve the request parameter using ServletRequest#getParameter and then use the retrieved encoding as shown in my previous answer.

from jodconverter.

evserykh avatar evserykh commented on May 12, 2024

@sbraconnier I got it. Thanks a lot for help

from jodconverter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.