TOP
Sentence Case الدالة لـ LibreOffice Cal
SENTENCECASE() الوصف
تم تصميم الدالة SENTENCECASE() لتحويل النص الموجود إلى تنسيق جملة وإرجاع مجموعة من الكلمات في النموذج: "Sentence case function" .
Sentence Case يقسم الأسطر المفصولة بنقاط أو علامات تعجب أو علامات استفهام إلى جمل منفصلة. ثم يحول كل الكلمات إلى أحرف صغيرة باستثناء الحرف الأول في الجملة ثم يجمع كل العناصر في نص واحد مستمر.
يمكن أن تكون الدالة SENTENCECASE() مفيدة لتصحيح حالة الأحرف في الجمل في النص بأكمله.
StarBASIC رمز SENTENCECASE()
إليك رمز الماكرو لإنشاء وظيفة مخصصة يمكنها ضبط حالة الكلمات في الجمل (Sentence Case) في LibreOffice Calc.
افتح القائمة Tools - Macros - Edit Macros...، وحدد Module1 وانسخ النص التالي إلى الوحدة:
- Function SentenceCase(ByVal str As String) As String
-
- Dim sentences As Variant
- Dim i As Integer
- Dim FCalc As Object
-
- FCalc = CreateUnoService("com.sun.star.sheet.FunctionAccess")
-
- str = Replace(str,"-"," ")
- str = Replace(str,"_"," ")
- str = FCalc.callFunction("TRIM", Array(str))
- str = LCase(str)
- str = FCalc.callFunction("REGEX", Array(str,"([.!?])(\s)(\w)","$1#$3","g"))
-
- sentences = Split(str, "#")
-
- For i = LBound(sentences) To UBound(sentences)
- sentences(i) = UCase(Left(sentences(i), 1)) & Mid(sentences(i), 2)
- Next i
-
- SentenceCase = Join(sentences," ")
- End Function
Function SentenceCase(ByVal str As String) As String
'moonexcel.com.ua
Dim sentences As Variant
Dim i As Integer
Dim FCalc As Object
FCalc = CreateUnoService("com.sun.star.sheet.FunctionAccess")
str = Replace(str,"-"," ")
str = Replace(str,"_"," ")
str = FCalc.callFunction("TRIM", Array(str))
str = LCase(str)
str = FCalc.callFunction("REGEX", Array(str,"([.!?])(\s)(\w)","$1#$3","g"))
sentences = Split(str, "#")
For i = LBound(sentences) To UBound(sentences)
sentences(i) = UCase(Left(sentences(i), 1)) & Mid(sentences(i), 2)
Next i
SentenceCase = Join(sentences," ")
End Function
ثم أغلق Macro Editor، وارجع إلى LibreOffice Calc واستخدم وظيفتنا الجديدة في أي خلية.
باستخدام التمديد
يمكنك أيضًا استخدام الميزة SENTENCECASE() عن طريق تثبيت الامتداد المجاني YouLibreCalc.oxt أو نسخته كاملة المواصفات YLC_Utilities.oxt .
بعد ذلك ستكون هذه الوظيفة متاحة في كافة الملفات التي سيتم فتحها في LibreOffice Calc.