Create Column Report

The first step is to add the headers which make this task function.

[codesyntax lang=”cpp”]

#include <iomanip>
#include <iostream>

[/codesyntax]

Next we must establish a stream connection.

[codesyntax lang=”cpp”]

 std::ofstream sw("textfile.txt");

[/codesyntax]

After all desired code placed on the stream be sure to close the stream.

[codesyntax lang=”cpp”]

    sw.close();

[/codesyntax]

We are now ready to add information to the stream.

[codesyntax lang=”cpp”]

    sw << " " << std::endl;
    sw << "Brooks Computing Systems, LLC " << std::endl;
    sw << "P. O. Box 7682 " << std::endl;
    sw << "Columbia Missouri 65205 " << std::endl;
    sw << " " << std::endl;
    sw << "E Mail : arch@archbrooks.us " << std::endl;
    sw << "Phone : 573 239 7736" << std::endl;
    sw << " " << std::endl;
    sw << " " << std::endl;

[/codesyntax]

When working with dollar values precision and dollar sign symbol  insertion.

[codesyntax lang=”cpp”]

std::string dlgRpt1::precisionDollars(const double x, const int decDigits)
{
    std::stringstream ss;
    ss << std::fixed;
    ss.precision(decDigits); // set # places after decimal
    ss << x;
    return ss.str();
}

[/codesyntax]

The symbol insertion method is listed below.

[codesyntax lang=”cpp”]

void dlgRpt1::dollarFormat(std::string &currency)
{
    int dp;
    dp = currency.find('.');
    if (dp > 3)
    {
        for (int x = dp - 3; x > 0; x -= 3)
            currency.insert(x, ",");
    }
    currency.insert(0, "$");

}

[/codesyntax]

With this level of offered software a column report is readily available.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

Leave a Reply

Your email address will not be published. Required fields are marked *