Results 1 to 4 of 4
  1. #1
    cathrop is offline Member
    Join Date
    Nov 2015
    Posts
    2
    Rep Power
    0

    Question replaceText of usermodel.Range class works on Windows but not on MAC

    My project takes a Word template and replaces placeholders with values from a Lotus Notes document. It is currently using LotusScript (VBA) to do this in Windows which means it is using OLE. OLE does not work on the MAC platform so am trying to get Apache POI to do the same thing on the MAC. I have found code to do this called "InsertText.java" and "ParagraphText.java" that does exactly what I need and works fine on the Windows platform. But when I try it on the MAC platform the replaceText method of t he usermodel.Range class gives the following error:
    method replacetext(String, String, int) is undefined for the type paragraph
    I am running this using the Eclipse IDE on both Windows and MAC and am using Apache POI version 3.13. The "import org.apache.poi.hwpf.usermodel.Range;".

    Is there a reason it works on Windows and on the MAC platform?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: replaceText of usermodel.Range class works on Windows but not on MAC

    What code is causing that error?
    Please post it here, in code tags, ensuring we know what types all the variables are.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    cathrop is offline Member
    Join Date
    Nov 2015
    Posts
    2
    Rep Power
    0

    Default Re: replaceText of usermodel.Range class works on Windows but not on MAC

    This is the code causing the error:
    <comment>
    // After the paragraph has been tested against all of the keys
    // for placeholders, check to see if any replacements were made.
    // If there were any replacements made then call the replaceText()
    // method for the specific paragraph. Here the paragraph's
    // number is recovered by calling the getParagraphNumber()
    // method - this could easily be replaced in the current
    // situation with the number i which is the index of the enclosing
    // for loop. If the updates were made in another loop however, the
    // availability of the paragraph number could be useful.
    //
    // Note that two further calls are made to get the raw text - the
    // text that was originally recovered from the paragraph - and the
    // updated text - the text with any placeholders replaced. It
    // proved necessary to copy the text recovered from the paragraph
    // Because a call to the text() method of the Paragraph object
    // only returned part of the text for the final paragraph.
    </comment>
    <code>
    if (paraText[i].isUpdated()) {
    range.getParagraph(paraText[i].getParagraphNumber()).replaceText(paraText[i].getRawText(),
    paraText[i].getUpdatedText(), 0);
    }
    </code>
    I have highlighted in blue the Range method that is getting the error.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: replaceText of usermodel.Range class works on Windows but not on MAC

    I'm going to guess that code was written for an earlier version of POI, as the current version does not have that method on Paragraph.

    Actually, no. That method is on Range, not Paragraph. That code is incorrect.

    Since the HWPF side of things hasn't had any lead developer on it for years, and was incomplete, it is possible that earlier versions had the replaceText method on Paragraph?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Code Logic Works On Windows but not Android
    By EBamber in forum Android
    Replies: 13
    Last Post: 05-04-2014, 10:19 PM
  2. Sounds not working on MAC, works on windows 7
    By natdizzle in forum Advanced Java
    Replies: 3
    Last Post: 12-16-2012, 03:06 AM
  3. Replies: 5
    Last Post: 04-02-2010, 03:33 PM
  4. Replies: 0
    Last Post: 04-02-2010, 05:54 AM
  5. Replies: 6
    Last Post: 10-22-2008, 05:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •