EzDevInfo.com

ms-word interview questions

Top ms-word frequently asked interview questions

Creating Microsoft Word (.docx) documents in Ruby

Is there an easy way to create Word documents (.docx) in a Ruby application? Actually, in my case it's a Rails application served from a Linux server.

A gem similar to Prawn but for DOCX instead of PDF would be great!


Source: (StackOverflow)

Mercurial and Word or PDF documents

is it possible to use Mercurial version control to track Word or PDF files? Is there any limitation or problem?


Source: (StackOverflow)

Advertisements

Reading/Writing a MS Word file in PHP

Is it possible to read and write Word (2003 and 2007) files in PHP without using a COM object? I know that I can:

$file = fopen('c:\file.doc', 'w+');
fwrite($file, $text);
fclose();

but Word will read it as an HTML file not a native .doc file.


Source: (StackOverflow)

Inserting newlines in Word using OpenXML

I am using openxml WordProcessingDocument to open a Word template and replace placeholder x1 with a string. This works fine unless I need the string to contain a newline. How can I replace x1 with text may contain newlines that word would recognise? I have tried \n \r but these do not work

Just to explain further when the word template is opened I read it into a StreamReader then use .Replace to replace x1.


Source: (StackOverflow)

How can I create a Word document using Python?

I'd like to create a Word document using Python, however, I want to re-use as much of my existing document-creation code as possible. I am currently using an XSLT to generate an HTML file that I programatically convert to a PDF file. However, my client is now requesting that the same document be made available in Word (.doc) format.

So far, I haven't had much luck finding any solutions to this problem. Is anyone aware of an open source library (or *gulp* a proprietary solution) that may help resolve this issue?

NOTE: All possible solutions must run on Linux. I believe this eliminates pywin32.


Source: (StackOverflow)

How to convert MS doc to pdf

How to convert doc to pdf using java api. where document contains various formats such as tables in ms word. when converting to pdf using iText. where actual document looks different to converted pdf. please provide any api not an exe installed for converting . must be an open source


Source: (StackOverflow)

Displaying a MS Word File in View(say TextView) in Android

I want to display a .docx file in a View in Android. The file has mathematical symbols and also images in between the text. I want to display many such files and flip through them via swipe gesture. I have successfully done the same for .txt files. And can now very easily go to the next page on swipe. The code for .txt file is as follows:

public String readTxt(String fileName)
    {


        try {
            InputStream is;
            is = context.getAssets().open(fileName + ".txt");
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

            int i;
            i = is.read();
            while (i != -1)
            {
                byteArrayOutputStream.write(i);
                i = is.read();
            }

            is.close();

            return byteArrayOutputStream.toString();

        } 

        catch (IOException e) 
        {
            e.printStackTrace();
        }

        return fileName;
    }

This code returns the text which I then display in my TextView. This way I only need to change the name of the file dynamically and on swipe the Text changes.

Now I want to modify this code so that I can display MS Word files(.docx) which contain text,images and mathematical symbols.

I have already checked many similar threads on this topic on stack overflow as well as on other forums: These are the links many people have suggested as answers to similar questions and I have already given these a try: Link1 and link2

Also on many other threads people have recommended Jopendocument. I have also read about that and learnt that Android does not support open document format. so that option seems unlikely. But if you have any workaround or a good detailed explanation with respect to adding the JOpenDocument library to the project and displaying rich text then please share that solution because I have searched for it a lot but couldn't find any.

There is also another library called OliveDocLibrary to display rich word files on android. here is the link from where I downloaded the lib. The demo included in that download package works just fine.But the lib is a trial version. So am currently trying to work with this library and see where it goes. But am still in search of better options.

Any help regarding this is appreciated. Any pointers other than the ones mentioned above are most welcome.

Update:

I got a suggestion which told the use of Apache POI(HWPF more specifically) in the first bounty I started on this question. After exploring Apache POI for some time, I got few codes which were writing into a doc file, reading the doc file, updating the excel sheets etc.

Such Sample code(for Java) which I found off the internet goes something like this:

import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;

public class ReadDocFile {
public static void main(String[] args) {
File file = null;
WordExtractor extractor = null ;
try {

file = new File("c:\\New.doc");
FileInputStream fis=new FileInputStream(file.getAbsolutePath());
HWPFDocument document=new HWPFDocument(fis);
extractor = new WordExtractor(document);
String [] fileData = extractor.getParagraphText();
for(int i=0;i<fileData.length;i++){
if(fileData[i] != null)
System.out.println(fileData[i]);
}
}
catch(Exception exep){}
}
}

So I added this library(Apache POI) to my Android project in eclipse and tried this sample code with some changes. And tried displaying it on a TextView. The problem here though is it doesn't display the images like OliveDocLibrary does. So if Someone is going to suggest Apache POI, then I request for a solid pointer or a code which reads a docx file and all its contents(that includes images) and displays them in a custom view.

Apache POI is a great thing but sadly I didn't find any good examples/samples implementing those libraries. If you know a good source of examples(w.r.t MS word only) then please share them in comments.

Update 2:

In OliveDocLibrary package the code provided works fine. There is water mark of Olive on the View though. Currently am working on performing Swipe on that code. But the problem remains that its a trial version.

Update 3:

I think OliveDocLibrary is the most efficient way to do it. Though it has a disadvantage of being a trial version, I think no other library does a better job than this library to full fill my specific requirement. The detailed answer has been posted below. As the bounty time is about to get over. I would request the people who may have an alternate and better solution to post it as soon as possible. For now am going with OliveDocLibrary and accepting my own answer.


Source: (StackOverflow)

Number of pages in a word doc in java

Is there an easy way to count the number of pages is a Word document either .doc or .docx?

Thanks


Source: (StackOverflow)

Can I merge two Microsoft Word documents reliably with Subversion? [closed]

We have concurrent edits happening on Word documents and I want to make sure that Subversion can handle merging .doc files. Do you know if Subversion handles merges of Word documents well?


Source: (StackOverflow)

How to extract text from word file .doc,docx,.xlsx,.pptx php

There may be a scenario we need to get the text from word documents for the future use to search the string in the document uploaded by user like for searching in cv's/resumes and occurs a common problem that how to get the text , Open and read a user uploaded Word document,there are some helpful links but don't cure the whole problem.We need to get the text at the time of uploading and save text in database and we can easily search within the database.

It’s OK to Ask and Answer Your Own Questions


Source: (StackOverflow)

Version Control for word documents [closed]

How would people recommend doing version control for word documents? Is the in build control up to the job or is it better to rely on dedicated version control systems, and if so, which ones?


Source: (StackOverflow)

How do you display code snippets in MS Word preserving format and syntax highlighting?

Does anyone know a way to display code in Microsoft Word documents that preserves coloring and formatting? Preferably, the method would also be unobtrusive and easy to update.

I have tried to include code as regular text which looks awful and gets in the way when editing regular text. I have also tried inserting objects, a WordPad document and Text Box, into the document then putting the code inside those objects. The code looks much better and is easier to avoid while editing the rest of the text. However, these objects can only span one page which makes editing a nightmare when several pages of code need to be added.

Lastly, I know that there are much better editors/formats that have no problem handling this but I am stuck working with MS word.


Source: (StackOverflow)

What's a good Java API for creating Word documents? [closed]

I have a new app I'll be working on where I have to generate a Word document that contains tables, graphs, a table of contents and text. What's a good API to use for this? How sure are you that it supports graphs, ToCs, and tables? What are some hidden gotcha's in using them?

Some clarifications:

  • I can't output a PDF, they want a Word doc.
  • They're using MS Word 2003 (or 2007), not OpenOffice
  • Application is running on *nix app-server

It'd be nice if I could start with a template doc and just fill in some spaces with tables, graphs, etc.

Edit: Several good answers below, each with their own faults as far as my current situation. Hard to pick a "final answer" from them. Think I'll leave it open, and hope for better solutions to be created.

Edit: The OpenOffice UNO project does seem to be closest to what I asked for. While POI is certainly more mainstream, it's too immature for what I want.


Source: (StackOverflow)

How can a Word document be created in C#? [closed]

I have a project where I would like to generate a report export in MS Word format. The report will include images/graphs, tables, and text. What is the best way to do this? Third party tools? What are your experiences?


Source: (StackOverflow)

Create Word Document using PHP in Linux

Whats the available solutions for PHP to create word document in linux environment?


Source: (StackOverflow)