This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

String Manipulation

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Java programmer,

I am building a string manipulator function in java. A list of long string will be sliced into a few parts before adding them into excel's cell.

Basically, I have defined the width of the cell in the excel template that i created. A cell will be able to show up to 160 characters, the 161st character would be shown on the next row

However there are a few rules:
1. If there is a carriage return, the next string after it will be put in the next row.
2. If the 160th character is part of a word, that word should be put in the next row. For example: "Manipulation" and the 160th char is "p", the whole word Manipulation will be inserted into the next row.

I have wrote the code but it is still not perfect yet. Anyone who can help me to correct it?

 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this some homework of yours or can you use a third-party API to solve this??
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have wrote the code but it is still not perfect yet. Anyone who can help me to correct it?


You have to be more specific.

Why is it "not perfect"? Does it compile? Does it run? If you are getting any compile time or runtime errors, what are the errors?

Is the output what you expect or not? If the result is different from what you expect, explain in detail what you expect and what it actually does.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never used this but found the page while searching the internet maybe it can help.

excel api
 
Maruli Lee
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stuart Ash: No, this is not a homework. This is the last part of a project I am working on (report generation)

Thomas Drew: Thanx for the link. Actually, I am using that API for my report generation.

Jesper de Jong:
Input String is:


Expected Output is:


Executed Output is:


P.S: Results are based on int iAllowedChar = 138

[ November 21, 2005: Message edited by: Maruli Lee ]

[ November 21, 2005: Message edited by: Maruli Lee ]
[ November 21, 2005: Message edited by: Maruli Lee ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic