ايران ويج

نسخه‌ی کامل: شمارش کلمات آفیس
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
سلام

چطور میشه تعداد کلمات فایل powerpoint رو شمارش کرد؟

ممنون
دوست عزیز منظورتون اینه که با کد نویسی اینکار را انجام بدی یا با خود افیس؟
مگه انجمن کد نویسی نیست؟

با کد نویسی
کلاسی با نام text manager که شامل متدهای زیر باشد
wordcount برای شمارش تعداد کلمات رشته ( wname)
space count تعداد space ها را می شمارد(sname)
paragraphcount تعداد پاراگرافهای متن را می شمارد (lname )
list word کلمات موجود در متن را به ترتیب از a تا z مرتب و چاپ می کند (lname )

کد:
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication16
{
    class Program
    {
        class textmanager
        {
            public int wordcount(string wname)
            {
                int index, count = 0;
                bool newword = true;
                for (index = 0; index < wname.Length; index++)
                    switch (wname[index])
                    {
                        case ' ':
                        case ',':
                        case '.':
                        case ':':
                        case ';':
                        case '?':
                            newword = true;
                            break;
                        default:
                            if (((wname[index] >= 'a') && (wname[index] <= 'z'))
                                || ((wname[index] >= 'A') && (wname[index] <= 'Z')))
                                if (newword == true)
                                {
                                    newword = false;
                                    count++;
                                }
                            break;
                    }
                return count;
            }

            public int spacecount(string sname)
            {
                int index, count = 0;
                for (index = 0; index < sname.Length; index++)
                    if (sname[index] == ' ')
                        count++;
                return count;
            }

            public int paragraphcount(string lname)
            {
                int index, count = 0;
                bool newline = true;
                for (index = 0; index < lname.Length; index++)
                    if (lname[index] == '\n')
                        newline = true;
                    else
                        if (newline == true)
                        {
                            count++;
                            newline = false;
                        }
                return count;
            }

            public void listword(string lname)
            {
                int index, count = 0, start = 0, i, j;
                string[] words = new string[lname.Length + 1];
                string temp;
                bool newword = true;
                for (index = 0; index < lname.Length; index++)
                    switch (lname[index])
                    {
                        case ' ':
                        case ',':
                        case '.':
                        case ':':
                        case ';':
                        case '?':
                            if (newword == false)
                            {
                                newword = true;
                                words[count - 1] = lname.Substring(start, index - start);
                            }
                            break;
                        default:
                            if (((lname[index] >= 'a') && (lname[index] <= 'z'))
                                || ((lname[index] >= 'A') && (lname[index] <= 'Z')))
                                if (newword == true)
                                {
                                    newword = false;
                                    start = index;
                                    count++;
                                }
                            break;
                    }
                if (newword == false)
                    words[count - 1] = lname.Substring(start, index - start);
                for (i = 2; i < count; i++)
                    for (j = 0; j < count - i; j++)
                        if (words[j].CompareTo(words[j + 1]) > 0)
                        {
                            temp = words[j];
                            words[j] = words[j + 1];
                            words[j + 1] = temp;
                        }
                for (i = 0; i < count; i++)
                    Console.WriteLine(words[i]);
            }
        }
        static void Main(string[] args)
        {
            textmanager t = new textmanager();
            Console.WriteLine(t.wordcount("This is a test"));
            Console.WriteLine(t.spacecount("This is a test"));
            Console.WriteLine(t.paragraphcount("Paragraph #1\nParagraph #2"));
            t.listword("This is a test");
            Console.ReadKey(true);
        }
    }
}