قالب‌بندی متن ارائه در جاوا

مرور کلی

این مقاله نشان می‌دهد چگونه می‌توان متن را در ارائه‌های PowerPoint و OpenDocument با استفاده از Aspose.Slides for Java قالب‌بندی کرد. این مقاله به رنگ‌های پس‌زمینه، شفافیت، فاصله‌گذاری کاراکترها، ویژگی‌های قلم، چرخش، فاصله‌بندی پاراگراف، رفتار خودکاراندازه‌گیری، لنگر متن، ایستگاه‌های تب و تنظیمات زبان می‌پردازد.

در مثال‌های زیر از فایلی به نام “sample.pptx” استفاده خواهیم کرد، که شامل یک جعبه متن در اسلاید اول با متن زیر است:

متن نمونه

برای یافتن و برجسته‌سازی متن دقیق یا مطابقت‌های عبارت منظم، به جستجو و جایگزینی متن مراجعه کنید.

تنظیم رنگ پس‌زمینه متن

از IParagraphFormat.getDefaultPortionFormat برای تنظیم رنگ برجسته پیش‌فرض یک پاراگراف استفاده کنید، یا از IBasePortionFormat.getHighlightColor برای بخش‌های متن منفرد استفاده کنید.

کد مثال زیر نشان می‌دهد چگونه می‌توان رنگ پس‌زمینه را برای تمام پاراگراف تنظیم کرد:

import com.aspose.slides.*;
import java.awt.Color;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    // رنگ برجسته را برای تمام پاراگراف تنظیم کنید.
    paragraph.getParagraphFormat().getDefaultPortionFormat().getHighlightColor().setColor(Color.LIGHT_GRAY);

    presentation.save("gray_paragraph.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

پاراگراف خاکستری

کد مثال زیر نشان می‌دهد چگونه می‌توان رنگ پس‌زمینه را برای بخش‌های متن با قلم بولد تنظیم کرد:

import com.aspose.slides.*;
import java.awt.Color;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    for (IPortion portion : paragraph.getPortions()) {
        if (portion.getPortionFormat().getEffective().getFontBold()) {
            // رنگ برجسته را برای بخش متن تنظیم کنید.
            portion.getPortionFormat().getHighlightColor().setColor(Color.LIGHT_GRAY);
        }
    }

    presentation.save("gray_text_portions.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

بخش‌های متن خاکستری

تراز پاراگراف‌های متن

از IParagraphFormat.setAlignment برای تنظیم تراز پاراگراف درون یک قاب متن استفاده کنید. مقدار می‌تواند وسط چین، چپ‌چین، راست‌چین، توجیه‌شده و غیره باشد.

کد مثال زیر نشان می‌دهد چگونه می‌توان پاراگراف را به مرکز تراز کرد:

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    // تراز پاراگراف را به مرکز تنظیم کنید.
    paragraph.getParagraphFormat().setAlignment(TextAlignment.Center);

    presentation.save("aligned_paragraph.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

پاراگراف تراز شده

تنظیم شفافیت برای متن

شفافیت متن از طریق مؤلفه آلفای رنگی که به IBasePortionFormat.getFillFormat اختصاص داده شده کنترل می‌شود. در مثال‌های زیر، alpha = 50 مقدار کانال آلفای ARGB در مقیاس ۰ تا ۲۵۵ است، نه درصد شفافیت.

کد مثال زیر نشان می‌دهد چگونه می‌توان شفافیت را برای تمام پاراگراف اعمال کرد:

import com.aspose.slides.*;
import java.awt.Color;

int alpha = 50;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    // رنگ پر کردن متن را به رنگ شفاف تنظیم کنید.
    paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat().setFillType(FillType.Solid);
    paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat().getSolidFillColor().setColor(new Color(0, 0, 0, alpha));

    presentation.save("transparent_paragraph.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

پاراگراف شفاف

کد مثال زیر نشان می‌دهد چگونه می‌توان شفافیت را برای بخش‌های متن با قلم بولد اعمال کرد:

import com.aspose.slides.*;
import java.awt.Color;

int alpha = 50;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    for (IPortion portion : paragraph.getPortions()) {
        if (portion.getPortionFormat().getEffective().getFontBold()) {
            // شفافیت بخش متن را تنظیم کنید.
            portion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
            portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(new Color(0, 0, 0, alpha));
        }
    }

    presentation.save("transparent_text_portions.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

بخش‌های متن شفاف

تنظیم فاصله کاراکتر برای متن

از IBasePortionFormat.setSpacing برای افزایش یا کاهش فاصله بین کاراکترها در یک جعبه متن استفاده کنید.

کد جاوا زیر نشان می‌دهد چگونه می‌توان فاصله کاراکترها را در تمام پاراگراف گسترش داد:

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    // توجه: برای فشرده‌سازی فاصله کاراکتر از مقادیر منفی استفاده کنید.
    paragraph.getParagraphFormat().getDefaultPortionFormat().setSpacing(3); // فاصله کاراکتر را گسترش دهید.

    presentation.save("character_spacing_in_paragraph.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

فاصله کاراکتر در پاراگراف

کد مثال زیر نشان می‌دهد چگونه می‌توان فاصله کاراکترها را در بخش‌های متن با قلم بولد گسترش داد:

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    for (IPortion portion : paragraph.getPortions()) {
        if (portion.getPortionFormat().getEffective().getFontBold()) {
            // توجه: برای فشرده‌سازی فاصله کاراکتر از مقادیر منفی استفاده کنید.
            portion.getPortionFormat().setSpacing(3); // فاصله کاراکتر را گسترش دهید.
        }
    }

    presentation.save("character_spacing_in_text_portions.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

فاصله کاراکتر در بخش‌های متن

غیرفعال کردن کرنینگ برای قلم‌های خاص

در برخی موارد، متنی که توسط Aspose.Slides رندر می‌شود ممکن است کمی فشرده‌تر از همان متن در PowerPoint به نظر برسد. این می‌تواند به این دلیل باشد که PowerPoint ممکن است داده‌های کرنینگ برای برخی قلم‌ها را نادیده بگیرد، حتی اگر قلم دارای اطلاعات کرنینگ معتبر باشد و کرنینگ در تنظیمات PowerPoint فعال باشد.

برای نزدیک‌تر کردن خروجی رندر شده به PowerPoint در این موارد، می‌توانید کرنینگ را برای بخش‌های متنی که از قلم مورد نظر استفاده می‌کنند غیرفعال کنید. مقدار IBasePortionFormat.setKerningMinimalSize را به عددی که به‌نظر بسیار بزرگتر از اندازه واقعی قلم باشد تنظیم کنید:

import com.aspose.slides.*;

Presentation presentation = new Presentation("presentation.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    String targetFont = "Roboto";

    for (IParagraph paragraph : autoShape.getTextFrame().getParagraphs()) {
        for (IPortion portion : paragraph.getPortions()) {
            IPortionFormat portionFormat = portion.getPortionFormat();

            if ((portionFormat.getLatinFont() != null &&
                 portionFormat.getLatinFont().getFontName().equals(targetFont)) ||
                (portionFormat.getEastAsianFont() != null &&
                 portionFormat.getEastAsianFont().getFontName().equals(targetFont)) ||
                (portionFormat.getComplexScriptFont() != null &&
                 portionFormat.getComplexScriptFont().getFontName().equals(targetFont))) {
                portionFormat.setKerningMinimalSize(100);
            }
        }
    }

    presentation.save("output.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

این تنظیم جلوی اعمال کرنینگ بر روی بخش‌های متنی مطابق را می‌گیرد و می‌تواند به هماهنگ‌سازی رندر Aspose.Slides با خروجی بصری PowerPoint برای قلم‌هایی که تحت تأثیر این رفتار خاص PowerPoint قرار دارند، کمک کند.

مدیریت ویژگی‌های قلم متن

ویژگی‌های قلم می‌توانند در سطح پاراگراف از طریق IParagraphFormat.getDefaultPortionFormat یا در بخش‌های منفرد از طریق IPortionFormat تنظیم شوند.

کد زیر ویژگی‌های قلم و سبک متن را برای تمام پاراگراف تنظیم می‌کند: اندازه قلم، بولد، ایتالیک، زیرخط نقطه‌ای و قلم Times New Roman را برای تمام بخش‌های پاراگراف اعمال می‌نماید:

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    // ویژگی‌های قلم را برای پاراگراف تنظیم کنید.
    paragraph.getParagraphFormat().getDefaultPortionFormat().setFontHeight(12);
    paragraph.getParagraphFormat().getDefaultPortionFormat().setFontBold(NullableBool.True);
    paragraph.getParagraphFormat().getDefaultPortionFormat().setFontItalic(NullableBool.True);
    paragraph.getParagraphFormat().getDefaultPortionFormat().setFontUnderline(TextUnderlineType.Dotted);
    paragraph.getParagraphFormat().getDefaultPortionFormat().setLatinFont(new FontData("Times New Roman"));

    presentation.save("font_properties_for_paragraph.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

ویژگی‌های قلم برای پاراگراف

کد مثال زیر ویژگی‌های مشابهی را برای بخش‌های متن با قلم بولد اعمال می‌کند:

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    for (IPortion portion : paragraph.getPortions()) {
        if (portion.getPortionFormat().getEffective().getFontBold()) {
            // ویژگی‌های قلم را برای بخش متن تنظیم کنید.
            portion.getPortionFormat().setFontHeight(13);
            portion.getPortionFormat().setFontItalic(NullableBool.True);
            portion.getPortionFormat().setFontUnderline(TextUnderlineType.Dotted);
            portion.getPortionFormat().setLatinFont(new FontData("Times New Roman"));
        }
    }

    presentation.save("font_properties_for_text_portions.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

ویژگی‌های قلم برای بخش‌های متن

تنظیم چرخش متن

از ITextFrameFormat.setTextVerticalType برای تنظیم جهت‌گیری پیش‌تعریف شده متن درون یک شکل استفاده کنید.

کد مثال زیر جهت‌گیری متن در شکل را به Vertical270 تنظیم می‌کند که متن را ۹۰ درجه در جهت پادساعتگرد می‌چرخاند:

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);

    autoShape.getTextFrame().getTextFrameFormat().setTextVerticalType(TextVerticalType.Vertical270);

    presentation.save("text_rotation.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

چرخش متن

تنظیم چرخش سفارشی برای فریم‌های متن

از ITextFrameFormat.setRotationAngle برای تنظیم زاویه چرخش سفارشی برای یک ITextFrame استفاده کنید.

کد مثال زیر فریم متن را درون شکل به میزان ۳ درجه در جهت ساعتگرد می‌چرخاند:

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);

    autoShape.getTextFrame().getTextFrameFormat().setRotationAngle(3);

    presentation.save("custom_text_rotation.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

چرخش سفارشی متن

تنظیم فاصله خط پاراگراف‌ها

Aspose.Slides متدهای IParagraphFormat.setSpaceAfter، IParagraphFormat.setSpaceBefore و IParagraphFormat.setSpaceWithin را برای کنترل فاصله‌بندی پاراگراف فراهم می‌کند. این خصوصیات به شکل زیر استفاده می‌شوند:

  • از مقدار مثبت برای مشخص کردن فاصله خط به صورت درصدی از ارتفاع خط استفاده کنید.
  • از مقدار منفی برای مشخص کردن فاصله خط به صورت نقطه استفاده کنید.

کد مثال زیر نشان می‌دهد چگونه می‌توان فاصله خط را درون پاراگراف مشخص کرد:

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    paragraph.getParagraphFormat().setSpaceWithin(200);

    presentation.save("line_spacing.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

فاصله خط درون پاراگراف

تنظیم نوع خودتنظیم برای فریم‌های متن

ITextFrameFormat.setAutofitType تعیین می‌کند که متن هنگام تجاوز از مرزهای حاوی خود چگونه رفتار کند. از آن برای کنترل اینکه متن کوچک شود، سرریز شود یا به‌صورت خودکار شکل را تغییر اندازه دهد استفاده کنید.

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);

    autoShape.getTextFrame().getTextFrameFormat().setAutofitType(TextAutofitType.Shape);

    presentation.save("autofit_type.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

تنظیم لنگر فریم‌های متن

ITextFrameFormat.setAnchoringType تعیین می‌کند که متن به صورت عمودی داخل یک شکل چگونه موقعیت پیدا کند، مثلا در بالا، وسط یا پایین.

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);

    autoShape.getTextFrame().getTextFrameFormat().setAnchoringType(TextAnchorType.Bottom);

    presentation.save("text_anchor.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

تنظیم تب متن

از IParagraphFormat.setDefaultTabSize و IParagraphFormat.getTabs برای پیکربندی ایستگاه‌های تب در یک پاراگراف استفاده کنید.

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);

    paragraph.getParagraphFormat().setDefaultTabSize(100);
    paragraph.getParagraphFormat().getTabs().add(30, TabAlignment.Left);

    presentation.save("paragraph_tabs.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

نتیجه:

تب‌های پاراگراف

تنظیم زبان اصلاح

Aspose.Slides متد IBasePortionFormat.setLanguageId را فراهم می‌کند که به شما امکان تنظیم زبان اصلاح برای یک بخش متن را می‌دهد. زبان اصلاح تعیین‌کننده زبانی است که برای بررسی املا و دستور زبان در PowerPoint استفاده می‌شود.

کد مثال زیر نشان می‌دهد چگونه می‌توان زبان اصلاح را برای یک بخش متن تنظیم کرد:

import com.aspose.slides.*;

Presentation presentation = new Presentation("presentation.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);

    IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);
    paragraph.getPortions().clear();

    FontData font = new FontData("SimSun");

    Portion textPortion = new Portion();
    textPortion.getPortionFormat().setComplexScriptFont(font);
    textPortion.getPortionFormat().setEastAsianFont(font);
    textPortion.getPortionFormat().setLatinFont(font);

    // شناسه زبان اصلاح را تنظیم کنید.
    textPortion.getPortionFormat().setLanguageId("zh-CN");

    textPortion.setText("1。");
    paragraph.getPortions().add(textPortion);

    presentation.save("proofing_language.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

تنظیم زبان پیش‌فرض

از LoadOptions.setDefaultTextLanguage برای تعریف زبان پیش‌فرض متنی که هنگام بارگذاری یا ایجاد یک ارائه ایجاد می‌شود استفاده کنید.

import com.aspose.slides.*;

LoadOptions loadOptions = new LoadOptions();
loadOptions.setDefaultTextLanguage("en-US");

Presentation presentation = new Presentation(loadOptions);
try {
    ISlide slide = presentation.getSlides().get_Item(0);

    // یک شکل مستطیل جدید با متن اضافه کنید.
    IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 150, 50);
    shape.getTextFrame().setText("Sample text");

    // زبان بخش اول را بررسی کنید.
    IPortion portion = shape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0);
    System.out.println(portion.getPortionFormat().getLanguageId());
} finally {
    presentation.dispose();
}

تنظیم سبک متن پیش‌فرض

برای اعمال قالب‌بندی متن پیش‌فرض در سطح ارائه، از IPresentation.getDefaultTextStyle استفاده کنید.

کد مثال زیر نشان می‌دهد چگونه می‌توان یک قلم بولد پیش‌فرض با اندازه ۱۴ pt برای تمام متن‌ها در تمام اسلایدهای یک ارائه جدید تنظیم کرد:

import com.aspose.slides.*;

Presentation presentation = new Presentation();
try {
    // دریافت قالب پاراگراف سطح بالا.
    IParagraphFormat paragraphFormat = presentation.getDefaultTextStyle().getLevel(0);

    if (paragraphFormat != null) {
        paragraphFormat.getDefaultPortionFormat().setFontHeight(14);
        paragraphFormat.getDefaultPortionFormat().setFontBold(NullableBool.True);
    }

    presentation.save("default_text_style.pptx", SaveFormat.Pptx);
} finally {
    presentation.dispose();
}

استخراج متن با اثر تمام حروف بزرگ

در PowerPoint، اعمال اثر All Caps بر قلم باعث می‌شود متن در اسلاید به صورت حروف بزرگ نمایش داده شود حتی اگر اصلاً به صورت حروف کوچک وارد شده باشد. هنگامی که یک بخش متن چنین را با Aspose.Slides بازیابی می‌کنید، کتابخانه متن را دقیقاً همان‌گونه که وارد شده است برمی‌گرداند. برای مطابقت با متن نمایش داده‌شده، TextCapType را بررسی کنید و زمانی که مقدار آن All است، رشته برگشتی را به حروف بزرگ تبدیل کنید.

فرض کنیم یک جعبه متن زیر را در اسلاید اول فایل sample2.pptx داریم.

اثر All Caps

کد مثال زیر نشان می‌دهد چگونه می‌توان متن را با اثر All Caps استخراج کرد:

import com.aspose.slides.*;

Presentation presentation = new Presentation("sample2.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IAutoShape autoShape = (IAutoShape)slide.getShapes().get_Item(0);
    IPortion textPortion = autoShape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0);

    System.out.println("Original text: " + textPortion.getText());

    IPortionFormatEffectiveData textFormat = textPortion.getPortionFormat().getEffective();
    if (textFormat.getTextCapType() == TextCapType.All) {
        String text = textPortion.getText().toUpperCase();
        System.out.println("All-Caps effect: " + text);
    }
} finally {
    presentation.dispose();
}

خروجی:

Original text: Hello, Aspose!
All-Caps effect: HELLO, ASPOSE!

پرسش‌های متداول

چگونه متن در یک جدول روی اسلید را ویرایش کنیم؟

برای تغییر متن در یک جدول روی اسلید، از ITable استفاده کنید. از طریق سلول‌ها پیمایش کنید و هر سلول را با استفاده از ICell.getTextFrame به‌روزرسانی کنید و قالب‌بندی پاراگراف را از طریق IParagraph.getParagraphFormat تنظیم نمایید.

چگونه رنگ گرادیان را به متن در یک اسلاید PowerPoint اعمال کنیم؟

برای اعمال رنگ گرادیان به متن، از IBasePortionFormat.getFillFormat استفاده کنید. مقدار IFillFormat.setFillType را به FillType.Gradient تنظیم کنید و ایستگاه‌های گرادیان، جهت و شفافیت را پیکربندی نمایید.