Hi
Thanks for your inquiry, You can create your own method to get letters and roman numbers. For example see the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Arabic
for (int i = 1; i <20; i++)
{
builder.insertField("SEQ Anbu \\* Arabic", String.valueOf(i));
builder.writeln(" test");
}
builder.writeln();
// Lowercase letter
for (int i = 1; i <20; i++)
{
builder.insertField("SEQ Anbu1 \\* Alphabetic", GetLowercaseLetter(i));
builder.writeln(" test");
}
builder.writeln();
// Roman
for (int i = 1; i <20; i++)
{
builder.insertField("SEQ Anbu2 \\* Roman", GetLowerRoman(i));
builder.writeln(" test");
}
doc.save("C:\\Temp\\out.doc");
/**
* Get value of lowercase letter a, b, c...aa, bb, cc...etc
* @param listItemIndex
* List item index, starts from 1. if value is lower or equel 0 then return empty string
* @return
* Value of lowercase letter a, b, c...aa, bb, cc...etc
*/
private static String GetLowercaseLetter(int listItemIndex)
{
// Validate
if (listItemIndex <= 0)
return "";
// 26 is letters count in English alphabet
int lettersCount = 26;
// Starting character
char currentChar = 'a';
// Working variable for building list label
String completeLabel = "";
// Count of leeter in list label
int count = listItemIndex / lettersCount + 1;
// Letter offset
int lettersOffset = listItemIndex % lettersCount;
// This is needed for 'z' character (it is 26th letter so offset=0)
if (lettersOffset == 0 && count> 0)
{
lettersOffset = lettersCount;
count--;
}
// Calculate current character
currentChar += (char)(lettersOffset - 1);
// Build label string
for (int i = 0; i <count; i++)
{
// if (remainders[i]>= 0)
completeLabel += currentChar;
}
return completeLabel;
}
/**
* Get value of lowercase roman numbers i, ii, iii, iv...etc
* @param listItemIndex
* List item index, starts from 1 and max value is 3 999.
* There is specific in displaing valies greater then 4 000 as Romn numbers. so we add this restriction.
* Empty string will be returned in case if value is lower or equel 0 or grater than 3 999
* @return
* Value of lowercase roman numbers i, ii, iii, iv...etc
*/
private static String GetLowerRoman(int listItemIndex)
{
// Validate
if (listItemIndex <= 0 || listItemIndex> 3999)
return "";
// Set up key numerals and numeral pairs
int[] values = new int[]
{
1000,
900,
500,
400,
100,
90,
50,
40,
10,
9,
5,
4,
1
};
String[] numerals = new String[]
{
"m",
"cm",
"d",
"cd",
"c",
"xc",
"l",
"xl",
"x",
"ix",
"v",
"iv",
"i"
};
// Working variable for building list label
String completeLabel = "";
// Loop through each of the values to diminish the number
for (int i = 0; i <values.length; i++)
{
// If the number being converted is less than the test value, append
// the corresponding numeral or numeral pair to the resultant string
while (listItemIndex>= values[i])
{
listItemIndex -= values[i];
completeLabel += numerals[i];
}
}
return completeLabel;
}
Hope this helps.
Best regards.