All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.docx4j.model.listnumbering.NumberFormatLowerLetter Maven / Gradle / Ivy

Go to download

docx4j is a library which helps you to work with the Office Open XML file format as used in docx documents, pptx presentations, and xlsx spreadsheets.

There is a newer version: 11.4.11
Show newest version
package org.docx4j.model.listnumbering;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NumberFormatLowerLetter extends NumberFormat
{
	protected static Logger log = LoggerFactory.getLogger(NumberFormatLowerLetter.class);
	
	
	// from https://stackoverflow.com/questions/11969840/how-to-convert-a-base-10-number-to-alphabetic-like-ordered-list-in-html
	public String format( int num ) {

	    String result = "";
	    while (num > 0) {
	      num--; // 1 => a, not 0 => a
	      int remainder = num % 26;
	      char digit = (char) (remainder + 97);
	      result = digit + result;
	      num = (num - remainder) / 26;
	    }

	    return result;
	  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy